Class: SyntaxTree::JSON::ObjectNode
- Inherits:
-
Struct
- Object
- Struct
- SyntaxTree::JSON::ObjectNode
- Defined in:
- lib/syntax_tree/json.rb
Overview
This contains an object node. The values argument to the struct is a hash.
Instance Attribute Summary collapse
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
Instance Attribute Details
#values ⇒ Object
Returns the value of attribute values
27 28 29 |
# File 'lib/syntax_tree/json.rb', line 27 def values @values end |
Instance Method Details
#format(q) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/syntax_tree/json.rb', line 28 def format(q) q.group do q.text("{") q.indent do q.breakable q.seplist(values, nil, :each_pair) do |key, value| q.group do q.text(key.to_json) q.text(": ") value.format(q) end end end q.breakable q.text("}") end end |
#pretty_print(q) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/syntax_tree/json.rb', line 48 def pretty_print(q) q.group(2, "(object", ")") do q.breakable q.text("values=") q.pp(values) end end |