Class: SyntaxTree::JSON::AST::Number

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/json/ast.rb

Overview

This represents a number in the tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:) ⇒ Number

Returns a new instance of Number.



78
79
80
# File 'lib/syntax_tree/json/ast.rb', line 78

def initialize(value:)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



76
77
78
# File 'lib/syntax_tree/json/ast.rb', line 76

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



82
83
84
# File 'lib/syntax_tree/json/ast.rb', line 82

def accept(visitor)
  visitor.visit_number(self)
end

#child_nodesObject Also known as: deconstruct



86
87
88
# File 'lib/syntax_tree/json/ast.rb', line 86

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



92
93
94
# File 'lib/syntax_tree/json/ast.rb', line 92

def deconstruct_keys(keys)
  { value: value }
end