Class: WarpDrive::Path
- Inherits:
-
Object
show all
- Defined in:
- lib/warp_drive/path.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent, path) ⇒ Path
7
8
9
10
|
# File 'lib/warp_drive/path.rb', line 7
def initialize(parent, path)
self.parent = parent
self.path = path.to_s
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/warp_drive/path.rb', line 12
def method_missing(sym, *args)
if sym == :rb || sym == :yml
return self.to_s + ".#{sym}"
else
WarpDrive::Path.new(self, sym)
end
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
4
5
6
|
# File 'lib/warp_drive/path.rb', line 4
def parent
@parent
end
|
#path ⇒ Object
Returns the value of attribute path.
5
6
7
|
# File 'lib/warp_drive/path.rb', line 5
def path
@path
end
|
Class Method Details
.method_missing(sym, *args) ⇒ Object
38
39
40
|
# File 'lib/warp_drive/path.rb', line 38
def method_missing(sym, *args)
WarpDrive::Path.new(nil, sym)
end
|
Instance Method Details
#/(other) ⇒ Object
32
33
34
|
# File 'lib/warp_drive/path.rb', line 32
def /(other)
File.expand_path(File.join(self.to_s, other.to_s))
end
|
#to_s ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/warp_drive/path.rb', line 20
def to_s
paths = [self.path]
par = self.parent
until par.nil?
paths << par.path
par = par.parent
end
paths << File.join(WarpDrive::ROOT)
path = File.expand_path(File.join(paths.reverse))
return path
end
|