Class: Sergio::ParsedDocument
- Inherits:
-
Object
- Object
- Sergio::ParsedDocument
- Includes:
- HashMethods
- Defined in:
- lib/sergio/sergio_parsed_document.rb
Instance Attribute Summary collapse
-
#parsed_hash ⇒ Object
Returns the value of attribute parsed_hash.
Instance Method Summary collapse
-
#initialize ⇒ ParsedDocument
constructor
A new instance of ParsedDocument.
- #set_element(path, val, options = {}) ⇒ Object
Methods included from HashMethods
#hash_from_path, #hash_recursive_append, #hash_recursive_merge_to_arrays, #value_at_path
Constructor Details
#initialize ⇒ ParsedDocument
Returns a new instance of ParsedDocument.
6 7 8 |
# File 'lib/sergio/sergio_parsed_document.rb', line 6 def initialize @parsed_hash = {} end |
Instance Attribute Details
#parsed_hash ⇒ Object
Returns the value of attribute parsed_hash.
4 5 6 |
# File 'lib/sergio/sergio_parsed_document.rb', line 4 def parsed_hash @parsed_hash end |
Instance Method Details
#set_element(path, val, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sergio/sergio_parsed_document.rb', line 10 def set_element(path, val, = {}) old_val = value_at_path(path.clone, self.parsed_hash) if [:as_array] && !val.is_a?(Array) && !old_val.is_a?(Array) val = [val] end h = hash_from_path(path, val) @parsed_hash = hash_recursive_append(self.parsed_hash, h) @parsed_hash end |