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