public Method

String.pathmap_partial(n)

Extract a partial path from the path. Include n directories from the front end (left hand side) if n is positive. Include |n| directories from the back end (right hand side) if n is negative.

Source Code

# File rake.rb, line 103
def pathmap_partial(n)
  dirs = File.dirname(self).pathmap_explode
  partial_dirs =
    if n > 0
      dirs[0...n]
    elsif n < 0
      dirs.reverse[0...-n].reverse
    else
      "."
    end
  File.join(partial_dirs)
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.