Class: RelPathname
Instance Method Summary collapse
- #+(p1) ⇒ Object
- #/(p) ⇒ 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
12 13 14 15 16 |
# File 'lib/relpathname.rb', line 12 def initialize p1 @initial_pwd = Pathname.pwd super p1 end |
Instance Method Details
#+(p1) ⇒ Object
32 33 34 |
# File 'lib/relpathname.rb', line 32 def + p1 RelPathname.new to_pn + p1 end |
#/(p) ⇒ Object
36 37 38 |
# File 'lib/relpathname.rb', line 36 def / p RelPathname.new to_pn + p end |
#<=>(p1) ⇒ Object
40 41 42 |
# File 'lib/relpathname.rb', line 40 def <=> p1 to_pn <=> p1 end |
#==(p1) ⇒ Object
44 45 46 |
# File 'lib/relpathname.rb', line 44 def == p1 to_pn == p1 end |
#===(p1) ⇒ Object
48 49 50 |
# File 'lib/relpathname.rb', line 48 def === p1 to_pn === p1 end |
#absolute? ⇒ Boolean
52 53 54 |
# File 'lib/relpathname.rb', line 52 def absolute? to_pn.absolute? end |
#basename ⇒ Object
56 57 58 |
# File 'lib/relpathname.rb', line 56 def basename RelPathname.new to_pn.basename end |
#children(*args) ⇒ Object
60 61 62 |
# File 'lib/relpathname.rb', line 60 def children *args to_pn.children(*args).map do |path| RelPathname.new path end end |
#cleanpath(*args) ⇒ Object
64 65 66 |
# File 'lib/relpathname.rb', line 64 def cleanpath *args RelPathname.new to_pn.cleanpath(*args) end |
#directory? ⇒ Boolean
68 69 70 |
# File 'lib/relpathname.rb', line 68 def directory? to_pn.directory? end |
#dirname ⇒ Object
72 73 74 |
# File 'lib/relpathname.rb', line 72 def dirname RelPathname.new to_pn.dirname end |
#executable? ⇒ Boolean
76 77 78 |
# File 'lib/relpathname.rb', line 76 def executable? to_pn.executable? end |
#executable_real? ⇒ Boolean
80 81 82 |
# File 'lib/relpathname.rb', line 80 def executable_real? to_pn.executable_real? end |
#extname ⇒ Object
84 85 86 |
# File 'lib/relpathname.rb', line 84 def extname RelPathname.new to_pn.extname end |
#file? ⇒ Boolean
88 89 90 |
# File 'lib/relpathname.rb', line 88 def file? to_pn.file? end |
#mkpath ⇒ Object
92 93 94 |
# File 'lib/relpathname.rb', line 92 def mkpath RelPathname.new to_pn.mkpath end |
#mtime ⇒ Object
96 97 98 |
# File 'lib/relpathname.rb', line 96 def mtime to_pn.mtime end |
#parent ⇒ Object
100 101 102 |
# File 'lib/relpathname.rb', line 100 def parent RelPathname.new to_pn.parent end |
#relative? ⇒ Boolean
104 105 106 |
# File 'lib/relpathname.rb', line 104 def relative? to_pn.relative? end |
#symlink? ⇒ Boolean
108 109 110 |
# File 'lib/relpathname.rb', line 108 def symlink? to_pn.symlink? end |
#to_path ⇒ Object
22 23 24 |
# File 'lib/relpathname.rb', line 22 def to_path (@initial_pwd + super).relative_path_from(Pathname.pwd).to_s end |
#to_pn ⇒ Object
18 19 20 |
# File 'lib/relpathname.rb', line 18 def to_pn Pathname.new to_path end |
#to_s ⇒ Object
27 28 29 30 |
# File 'lib/relpathname.rb', line 27 def to_s prefix = to_pn.each_filename.to_a[0] == '..' ? '' : './' prefix + to_path end |