Class: JsonToGraphql::Parser::Node
- Inherits:
-
Object
- Object
- JsonToGraphql::Parser::Node
- Defined in:
- lib/json_to_graphql/parser.rb
Constant Summary collapse
- SPACES_PER_TAB =
2
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(name:, args:, attrs:) ⇒ Node
constructor
A new instance of Node.
- #print(string, level) ⇒ Object
Constructor Details
#initialize(name:, args:, attrs:) ⇒ Node
34 35 36 37 38 39 40 |
# File 'lib/json_to_graphql/parser.rb', line 34 def initialize(name:, args:, attrs:) @name = name @children = [] @attrs = attrs || [] @args = args || {} @variables = {} end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
31 32 33 |
# File 'lib/json_to_graphql/parser.rb', line 31 def args @args end |
#attrs ⇒ Object
Returns the value of attribute attrs.
31 32 33 |
# File 'lib/json_to_graphql/parser.rb', line 31 def attrs @attrs end |
#children ⇒ Object
Returns the value of attribute children.
31 32 33 |
# File 'lib/json_to_graphql/parser.rb', line 31 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/json_to_graphql/parser.rb', line 31 def name @name end |
#variables ⇒ Object
Returns the value of attribute variables.
31 32 33 |
# File 'lib/json_to_graphql/parser.rb', line 31 def variables @variables end |
Instance Method Details
#print(string, level) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/json_to_graphql/parser.rb', line 42 def print(string, level) indentation = " " * (level * SPACES_PER_TAB) next_level_indentation = " " * ((level.succ) * SPACES_PER_TAB) string.concat(indentation, "#{name}", arg_var_string, "{\n") attrs.each { |attr| string.concat(next_level_indentation, "#{attr}\n") } children.each { |child| child.print(string, level.succ) } string.concat(indentation, "}\n") end |