class Aruba::ArubaPath
Pathname for aruba files and directories
@private
Public Class Methods
new(path)
click to toggle source
# File lib/aruba/aruba_path.rb, line 9 def initialize(path) @obj = [path.to_s].flatten end
Public Instance Methods
[](index)
click to toggle source
Return string at index
@param [Integer, Range] index
# File lib/aruba/aruba_path.rb, line 51 def [](index) to_s[index] end
pop()
click to toggle source
Remove last pushed component of path
@example
path = ArubaPath.new 'path/to' path.push 'dir' path.pop puts path # => path/to
# File lib/aruba/aruba_path.rb, line 44 def pop @obj.pop end
push(p)
click to toggle source
Add directory/file to path
@param [String] p
The path to be added
@example
path = ArubaPath.new 'path/to/dir.d' path << 'subdir.d # or path.push 'subdir.d puts path # => path/to/dir.d/subdir.d
# File lib/aruba/aruba_path.rb, line 32 def push(p) @obj << p end
Also aliased as: <<
to_s()
click to toggle source
# File lib/aruba/aruba_path.rb, line 17 def to_s to_str end
to_str()
click to toggle source
# File lib/aruba/aruba_path.rb, line 13 def to_str to_pathname.to_s end
Private Instance Methods
to_pathname()
click to toggle source
Get path
# File lib/aruba/aruba_path.rb, line 58 def to_pathname current_path = @obj.inject do |path, element| if element.start_with?("~") || Aruba.platform.absolute_path?(element) element else File.join(path, element) end end ::Pathname.new(current_path) end