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
- #exist? ⇒ Boolean
- #extname ⇒ Object
- #file? ⇒ Boolean
-
#initialize(p1) ⇒ RelPathname
constructor
A new instance of RelPathname.
- #mkpath ⇒ Object
- #mtime ⇒ Object
- #parent ⇒ Object
- #pwd ⇒ Object
- #relative? ⇒ Boolean
- #symlink? ⇒ Boolean
- #to_origin_s ⇒ Object
- #to_path ⇒ Object
- #to_pn ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(p1) ⇒ RelPathname
Returns a new instance of RelPathname.
13 14 15 16 17 18 |
# File 'lib/relpathname.rb', line 13 def initialize p1 @initial_pwd = Pathname.pwd @origin_path = p1 super p1 end |
Instance Method Details
#+(p1) ⇒ Object
37 38 39 |
# File 'lib/relpathname.rb', line 37 def + p1 RelPathname.new to_pn + p1 end |
#/(p) ⇒ Object
41 42 43 |
# File 'lib/relpathname.rb', line 41 def / p RelPathname.new to_pn + p end |
#<=>(p1) ⇒ Object
45 46 47 |
# File 'lib/relpathname.rb', line 45 def <=> p1 to_pn <=> p1 end |
#==(p1) ⇒ Object
49 50 51 |
# File 'lib/relpathname.rb', line 49 def == p1 to_pn == p1 end |
#===(p1) ⇒ Object
53 54 55 |
# File 'lib/relpathname.rb', line 53 def === p1 to_pn === p1 end |
#absolute? ⇒ Boolean
57 58 59 |
# File 'lib/relpathname.rb', line 57 def absolute? to_pn.absolute? end |
#basename ⇒ Object
61 62 63 |
# File 'lib/relpathname.rb', line 61 def basename RelPathname.new to_pn.basename end |
#children(*args) ⇒ Object
65 66 67 |
# File 'lib/relpathname.rb', line 65 def children *args to_pn.children(*args).map do |path| RelPathname.new path end end |
#cleanpath(*args) ⇒ Object
69 70 71 |
# File 'lib/relpathname.rb', line 69 def cleanpath *args RelPathname.new to_pn.cleanpath(*args) end |
#directory? ⇒ Boolean
73 74 75 |
# File 'lib/relpathname.rb', line 73 def directory? to_pn.directory? end |
#dirname ⇒ Object
77 78 79 |
# File 'lib/relpathname.rb', line 77 def dirname RelPathname.new to_pn.dirname end |
#executable? ⇒ Boolean
81 82 83 |
# File 'lib/relpathname.rb', line 81 def executable? to_pn.executable? end |
#executable_real? ⇒ Boolean
85 86 87 |
# File 'lib/relpathname.rb', line 85 def executable_real? to_pn.executable_real? end |
#exist? ⇒ Boolean
121 122 123 |
# File 'lib/relpathname.rb', line 121 def exist? Pathname.new(to_s).exist? end |
#extname ⇒ Object
89 90 91 |
# File 'lib/relpathname.rb', line 89 def extname RelPathname.new to_pn.extname end |
#file? ⇒ Boolean
93 94 95 |
# File 'lib/relpathname.rb', line 93 def file? to_pn.file? end |
#mkpath ⇒ Object
97 98 99 |
# File 'lib/relpathname.rb', line 97 def mkpath RelPathname.new to_pn.mkpath end |
#mtime ⇒ Object
101 102 103 |
# File 'lib/relpathname.rb', line 101 def mtime to_pn.mtime end |
#parent ⇒ Object
105 106 107 |
# File 'lib/relpathname.rb', line 105 def parent RelPathname.new to_pn.parent end |
#pwd ⇒ Object
117 118 119 |
# File 'lib/relpathname.rb', line 117 def pwd RelPathname.new '.' end |
#relative? ⇒ Boolean
109 110 111 |
# File 'lib/relpathname.rb', line 109 def relative? to_pn.relative? end |
#symlink? ⇒ Boolean
113 114 115 |
# File 'lib/relpathname.rb', line 113 def symlink? to_pn.symlink? end |
#to_origin_s ⇒ Object
28 29 30 |
# File 'lib/relpathname.rb', line 28 def to_origin_s @origin_path end |
#to_path ⇒ Object
24 25 26 |
# File 'lib/relpathname.rb', line 24 def to_path (@initial_pwd + super).relative_path_from(Pathname.pwd).to_s end |
#to_pn ⇒ Object
20 21 22 |
# File 'lib/relpathname.rb', line 20 def to_pn Pathname.new to_path end |
#to_s ⇒ Object
32 33 34 35 |
# File 'lib/relpathname.rb', line 32 def to_s prefix = to_pn.each_filename.to_a[0] == '..' ? '' : './' prefix + to_path end |