class Hocon::Impl::PathBuilder

Public Class Methods

new() click to toggle source
# File lib/hocon/impl/path_builder.rb, line 8
def initialize
  @keys = []
  @result = nil
end

Public Instance Methods

append_key(key) click to toggle source
# File lib/hocon/impl/path_builder.rb, line 19
def append_key(key)
  check_can_append
  @keys.push(key)
end
append_path(path) click to toggle source
# File lib/hocon/impl/path_builder.rb, line 24
def append_path(path)
  check_can_append

  first = path.first
  remainder = path.remainder

  loop do
    @keys.push(first)

    if !remainder.nil?
      first = remainder.first
      remainder = remainder.remainder
    else
      break
    end
  end
end
check_can_append() click to toggle source
# File lib/hocon/impl/path_builder.rb, line 13
def check_can_append
  if @result
    raise Hocon::ConfigError::ConfigBugOrBrokenError, "Adding to PathBuilder after getting result"
  end
end
result() click to toggle source
# File lib/hocon/impl/path_builder.rb, line 42
def result
  # note: if keys is empty, we want to return nil, which is a valid
  # empty path
  if @result.nil?
    remainder = nil
    while !@keys.empty?
      key = @keys.pop
      remainder = Hocon::Impl::Path.new(key, remainder)
    end
    @result = remainder
  end
  @result
end