Class: EacRubyUtils::PathsHash
- Defined in:
- lib/eac_ruby_utils/paths_hash.rb
Defined Under Namespace
Classes: EntryKeyError, Node
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #[](entry_key) ⇒ Object
- #[]=(entry_key, entry_value) ⇒ Object
-
#initialize(source_hash = {}) ⇒ PathsHash
constructor
A new instance of PathsHash.
- #to_h ⇒ Object
Constructor Details
Instance Attribute Details
Class Method Details
.parse_entry_key(entry_key) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/eac_ruby_utils/paths_hash.rb', line 9 def parse_entry_key(entry_key) r = entry_key.to_s.strip raise EntryKeyError, 'Entry key cannot start or end with dot' if r.start_with?('.') || r.end_with?('.') r = r.split('.').map(&:strip) raise EntryKeyError, "Entry key \"#{entry_key}\" is empty" if r.empty? return r.map(&:to_sym) unless r.any?(&:blank?) raise EntryKeyError, "Entry key \"#{entry_key}\" has at least one blank part" end |
Instance Method Details
#[](entry_key) ⇒ Object
28 29 30 |
# File 'lib/eac_ruby_utils/paths_hash.rb', line 28 def [](entry_key) root.read_entry(self.class.parse_entry_key(entry_key), []) end |