Class: EacConfig::YamlFileNode::SelfEntries::DataNode

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_config/yaml_file_node/self_entries.rb

Instance Method Summary collapse

Instance Method Details

#child(child_key) ⇒ DataNode

Returns:



34
35
36
37
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 34

def child(child_key)
  self.class.new(data_node.fetch(child_key), path_from.with_last(child_key),
                 path_to.without_first)
end

#childrenObject



39
40
41
42
43
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 39

def children
  return [] unless data_node.is_a?(::Hash)

  data_node.keys.select { |k| key_matcher.match?(k) }.map { |k| child(k) }
end

#keySymbol

Returns:

  • (Symbol)


46
47
48
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 46

def key
  path_to.first
end

#key_matcherEacRubyUtils::Wildcards

Returns:

  • (EacRubyUtils::Wildcards)


51
52
53
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 51

def key_matcher
  @key_matcher ||= ::EacRubyUtils::Wildcards.new(key)
end

#resultArray<EacConfig::EntryPath>

Returns:



56
57
58
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 56

def result
  (path_to.empty? ? result_from_self : result_from_children)
end

#result_from_childrenArray<EacConfig::EntryPath>

Returns:



66
67
68
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 66

def result_from_children
  children.flat_map(&:result)
end

#result_from_selfArray<EacConfig::EntryPath>

Returns:



61
62
63
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 61

def result_from_self
  [path_from]
end