class Hypostasis::KeyPath

Public Class Methods

new(*path) click to toggle source
# File lib/hypostasis/key_path.rb, line 2
def initialize(*path)
  @path = path.to_a.flatten
  raise Hypostasis::Errors::InvalidKeyPath if @path.empty?
  self
end

Public Instance Methods

extend_path(*extension) click to toggle source
# File lib/hypostasis/key_path.rb, line 16
def extend_path(*extension)
  return self if extension.empty?
  extended_path = @path + extension.to_a
  Hypostasis::KeyPath.new(extended_path)
end
move_up(count = 0) click to toggle source
# File lib/hypostasis/key_path.rb, line 22
def move_up(count = 0)
  return self if count <= 0
  raise Hypostasis::Errors::KeyPathExhausted if count >= @path.size
  new_path = @path
  new_path.pop(count)
  Hypostasis::KeyPath.new(new_path)
end
to_a() click to toggle source
# File lib/hypostasis/key_path.rb, line 12
def to_a
  @path
end
to_s() click to toggle source
# File lib/hypostasis/key_path.rb, line 8
def to_s
  @path.join('\\')
end