Class: Krikri::JsonParser::Value
- Inherits:
-
Parser::Value
- Object
- Parser::Value
- Krikri::JsonParser::Value
- Defined in:
- lib/krikri/parsers/json_parser.rb
Overview
JsonParser::Value
Instance Attribute Summary collapse
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
- #attributes ⇒ Object
- #children ⇒ Object
-
#initialize(node) ⇒ Value
constructor
A new instance of Value.
- #value ⇒ Object
- #values? ⇒ Boolean
Methods inherited from Parser::Value
#[], #attribute?, #child?, #method_missing, #respond_to_missing
Constructor Details
#initialize(node) ⇒ Value
Returns a new instance of Value.
25 26 27 |
# File 'lib/krikri/parsers/json_parser.rb', line 25 def initialize(node) @node = node end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Krikri::Parser::Value
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
23 24 25 |
# File 'lib/krikri/parsers/json_parser.rb', line 23 def node @node end |
Instance Method Details
#attributes ⇒ Object
29 30 31 |
# File 'lib/krikri/parsers/json_parser.rb', line 29 def attributes raise NotImplementedError, 'Attributes are not supported for JSON' end |
#children ⇒ Object
33 34 35 |
# File 'lib/krikri/parsers/json_parser.rb', line 33 def children @node.is_a?(Hash) ? @node.keys : [] end |
#value ⇒ Object
37 38 39 |
# File 'lib/krikri/parsers/json_parser.rb', line 37 def value @node.is_a?(Hash) ? @node.to_s : @node end |
#values? ⇒ Boolean
41 42 43 |
# File 'lib/krikri/parsers/json_parser.rb', line 41 def values? !select_values.empty? end |