Class: Scorpio::JSON::HashNode
- Includes:
- Hashlike
- Defined in:
- lib/scorpio/json/node.rb
Constant Summary
Constants included from Hashlike
Hashlike::DESTRUCTIVE_METHODS, Hashlike::SAFE_KEY_ONLY_METHODS, Hashlike::SAFE_KEY_VALUE_METHODS, Hashlike::SAFE_METHODS
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#as_json ⇒ Object
needs redefined after including Enumerable.
- #each(&block) ⇒ Object
- #to_hash ⇒ Object
Methods included from Hashlike
#inspect, #pretty_print, #to_s
Methods inherited from Node
#[], #content, #deref, #document_node, #fingerprint, #fragment, #initialize, #inspect, #modified_copy, new_by_type, #object_group_text, #parent_node, #pointer_path, #pretty_print
Methods included from FingerprintHash
Constructor Details
This class inherits a constructor from Scorpio::JSON::Node
Instance Method Details
#as_json ⇒ Object
needs redefined after including Enumerable
236 237 238 |
# File 'lib/scorpio/json/node.rb', line 236 def as_json # needs redefined after including Enumerable Typelike.as_json(content) end |
#each(&block) ⇒ Object
220 221 222 223 224 225 226 227 228 |
# File 'lib/scorpio/json/node.rb', line 220 def each(&block) return to_enum(__method__) { content.size } unless block_given? if block.arity > 1 content.each_key { |k| yield k, self[k] } else content.each_key { |k| yield [k, self[k]] } end self end |
#to_hash ⇒ Object
230 231 232 |
# File 'lib/scorpio/json/node.rb', line 230 def to_hash inject({}) { |h, (k, v)| h[k] = v; h } end |