class KeyPath::Path

The class representing a Path in a collection object.

Public Class Methods

new(path = '') click to toggle source
# File lib/key_path/path.rb, line 4
def initialize(path = '')
  @path = path
end

Public Instance Methods

inspect() click to toggle source
# File lib/key_path/path.rb, line 27
def inspect
  "#<#{self.class.name}:#{object_id} path=#{@path}>"
end
parent() click to toggle source
# File lib/key_path/path.rb, line 8
def parent
  s = to_a
  s.pop

  # there's no parent if it's empty
  return nil if s == []

  # otherwise, join them back together and pass back a path
  s.join('.').to_keypath
end
to_a() click to toggle source
# File lib/key_path/path.rb, line 23
def to_a
  @path.split('.')
end
to_s() click to toggle source
# File lib/key_path/path.rb, line 19
def to_s
  @path
end