Class: RelPathname
- Inherits:
-
Pathname
- Object
- Pathname
- RelPathname
- Defined in:
- lib/relpathname.rb
Instance Method Summary collapse
- #+(p1) ⇒ Object
- #<=>(p1) ⇒ Object
- #==(p1) ⇒ Object
- #===(p1) ⇒ Object
- #absolute? ⇒ Boolean
- #basename ⇒ Object
- #children(*args) ⇒ Object
- #cleanpath(*args) ⇒ Object
- #directory? ⇒ Boolean
- #dirname ⇒ Object
- #executable? ⇒ Boolean
- #executable_real? ⇒ Boolean
- #extname ⇒ Object
- #file? ⇒ Boolean
-
#initialize(p1) ⇒ RelPathname
constructor
A new instance of RelPathname.
- #mkpath ⇒ Object
- #mtime ⇒ Object
- #parent ⇒ Object
- #relative? ⇒ Boolean
- #symlink? ⇒ Boolean
- #to_path ⇒ Object
- #to_pn ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(p1) ⇒ RelPathname
Returns a new instance of RelPathname.
6 7 8 9 10 |
# File 'lib/relpathname.rb', line 6 def initialize p1 @initial_pwd = Pathname.pwd super p1 end |
Instance Method Details
#+(p1) ⇒ Object
26 27 28 |
# File 'lib/relpathname.rb', line 26 def + p1 RelPathname.new to_pn + p1 end |
#<=>(p1) ⇒ Object
30 31 32 |
# File 'lib/relpathname.rb', line 30 def <=> p1 to_pn <=> p1 end |
#==(p1) ⇒ Object
34 35 36 |
# File 'lib/relpathname.rb', line 34 def == p1 to_pn == p1 end |
#===(p1) ⇒ Object
38 39 40 |
# File 'lib/relpathname.rb', line 38 def === p1 to_pn === p1 end |
#absolute? ⇒ Boolean
42 43 44 |
# File 'lib/relpathname.rb', line 42 def absolute? to_pn.absolute? end |
#basename ⇒ Object
46 47 48 |
# File 'lib/relpathname.rb', line 46 def basename RelPathname.new to_pn.basename end |
#children(*args) ⇒ Object
50 51 52 |
# File 'lib/relpathname.rb', line 50 def children *args to_pn.children(*args).map do |path| RelPathname.new path end end |
#cleanpath(*args) ⇒ Object
54 55 56 |
# File 'lib/relpathname.rb', line 54 def cleanpath *args RelPathname.new to_pn.cleanpath(*args) end |
#directory? ⇒ Boolean
58 59 60 |
# File 'lib/relpathname.rb', line 58 def directory? to_pn.directory? end |
#dirname ⇒ Object
62 63 64 |
# File 'lib/relpathname.rb', line 62 def dirname RelPathname.new to_pn.dirname end |
#executable? ⇒ Boolean
66 67 68 |
# File 'lib/relpathname.rb', line 66 def executable? to_pn.executable? end |
#executable_real? ⇒ Boolean
70 71 72 |
# File 'lib/relpathname.rb', line 70 def executable_real? to_pn.executable_real? end |
#extname ⇒ Object
74 75 76 |
# File 'lib/relpathname.rb', line 74 def extname RelPathname.new to_pn.extname end |
#file? ⇒ Boolean
78 79 80 |
# File 'lib/relpathname.rb', line 78 def file? to_pn.file? end |
#mkpath ⇒ Object
82 83 84 |
# File 'lib/relpathname.rb', line 82 def mkpath RelPathname.new to_pn.mkpath end |
#mtime ⇒ Object
86 87 88 |
# File 'lib/relpathname.rb', line 86 def mtime to_pn.mtime end |
#parent ⇒ Object
90 91 92 |
# File 'lib/relpathname.rb', line 90 def parent RelPathname.new to_pn.parent end |
#relative? ⇒ Boolean
94 95 96 |
# File 'lib/relpathname.rb', line 94 def relative? to_pn.relative? end |
#symlink? ⇒ Boolean
98 99 100 |
# File 'lib/relpathname.rb', line 98 def symlink? to_pn.symlink? end |
#to_path ⇒ Object
16 17 18 |
# File 'lib/relpathname.rb', line 16 def to_path (@initial_pwd + super).relative_path_from(Pathname.pwd).to_s end |
#to_pn ⇒ Object
12 13 14 |
# File 'lib/relpathname.rb', line 12 def to_pn Pathname.new to_path end |
#to_s ⇒ Object
21 22 23 24 |
# File 'lib/relpathname.rb', line 21 def to_s prefix = to_pn.each_filename.to_a[0] == '..' ? '' : './' prefix + to_path end |