Class: EacConfig::YamlFileNode::SelfEntries::DataNode
- Inherits:
-
Object
- Object
- EacConfig::YamlFileNode::SelfEntries::DataNode
- Defined in:
- lib/eac_config/yaml_file_node/self_entries.rb
Instance Method Summary collapse
- #child(child_key) ⇒ DataNode
- #children ⇒ Object
- #key ⇒ Symbol
- #key_matcher ⇒ EacRubyUtils::Wildcards
- #result ⇒ Array<EacConfig::EntryPath>
- #result_from_children ⇒ Array<EacConfig::EntryPath>
- #result_from_self ⇒ Array<EacConfig::EntryPath>
Instance Method Details
#child(child_key) ⇒ DataNode
33 34 35 36 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 33 def child(child_key) self.class.new(data_node.fetch(child_key), path_from.with_last(child_key), path_to.without_first) end |
#children ⇒ Object
38 39 40 41 42 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 38 def children return [] unless data_node.is_a?(::Hash) data_node.keys.select { |k| key_matcher.match?(k) }.map { |k| child(k) } # rubocop:disable Style/SelectByRegexp end |
#key ⇒ Symbol
45 46 47 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 45 def key path_to.first end |
#key_matcher ⇒ EacRubyUtils::Wildcards
50 51 52 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 50 def key_matcher @key_matcher ||= ::EacRubyUtils::Wildcards.new(key) end |
#result ⇒ Array<EacConfig::EntryPath>
55 56 57 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 55 def result (path_to.empty? ? result_from_self : result_from_children) end |
#result_from_children ⇒ Array<EacConfig::EntryPath>
65 66 67 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 65 def result_from_children children.flat_map(&:result) end |
#result_from_self ⇒ Array<EacConfig::EntryPath>
60 61 62 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 60 def result_from_self [path_from] end |