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
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 |
#children ⇒ Object
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) } # rubocop:disable Style/SelectByRegexp end |
#key ⇒ Symbol
46 47 48 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 46 def key path_to.first end |
#key_matcher ⇒ 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 |
#result ⇒ Array<EacConfig::EntryPath>
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_children ⇒ Array<EacConfig::EntryPath>
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_self ⇒ Array<EacConfig::EntryPath>
61 62 63 |
# File 'lib/eac_config/yaml_file_node/self_entries.rb', line 61 def result_from_self [path_from] end |