Class: BabelDiff::HashFlattener
- Inherits:
-
Struct
- Object
- Struct
- BabelDiff::HashFlattener
- Defined in:
- lib/babel_diff/yaml_differ.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
Instance Method Summary collapse
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash
66 67 68 |
# File 'lib/babel_diff/yaml_differ.rb', line 66 def hash @hash end |
Instance Method Details
#flat_hash ⇒ Object
81 82 83 |
# File 'lib/babel_diff/yaml_differ.rb', line 81 def flat_hash @_flat_hash ||= {} end |
#flatten(current_hash = hash, keys = []) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/babel_diff/yaml_differ.rb', line 68 def flatten(current_hash = hash, keys = []) current_hash.each do |key, value| new_keys = keys.dup << key if value.is_a? Hash flatten(value, new_keys) else flat_hash[new_keys.join(".")] = value end end flat_hash end |