class ConfigNodePath

Constants

Tokens

Attributes

tokens[R]

Public Class Methods

new(path, tokens) click to toggle source
# File lib/hocon/impl/config_node_path.rb, line 11
def initialize(path, tokens)
  @path = path
  @tokens = tokens
end

Public Instance Methods

first() click to toggle source
# File lib/hocon/impl/config_node_path.rb, line 38
def first
  tokens_copy = tokens.clone
  (0..tokens_copy.size - 1).each do |i|
    if Tokens.unquoted_text?(tokens_copy[i]) &&
        tokens_copy[i].token_text == "."
      return self.class.new(@path.sub_path(0, 1), tokens_copy[0, i])
    end
  end
  self
end
sub_path(to_remove) click to toggle source
# File lib/hocon/impl/config_node_path.rb, line 22
def sub_path(to_remove)
  period_count = 0
  tokens_copy = tokens.clone
  (0..tokens_copy.size - 1).each do |i|
    if Tokens.unquoted_text?(tokens_copy[i]) &&
        tokens_copy[i].token_text == "."
      period_count += 1
    end

    if period_count == to_remove
      return self.class.new(@path.sub_path_to_end(to_remove), tokens_copy[i + 1..tokens_copy.size])
    end
  end
  raise ConfigBugOrBrokenError, "Tried to remove too many elements from a Path node"
end
value() click to toggle source
# File lib/hocon/impl/config_node_path.rb, line 18
def value
  @path
end