Class: SyntaxTree::RationalLiteral
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::RationalLiteral
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
RationalLiteral represents the use of a rational number literal.
1r
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ RationalLiteral
Returns a new instance of RationalLiteral.
8920
8921
8922
8923
8924
|
# File 'lib/syntax_tree/node.rb', line 8920
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8918
8919
8920
|
# File 'lib/syntax_tree/node.rb', line 8918
def
@comments
end
|
#value ⇒ Object
- String
-
the rational number literal
8915
8916
8917
|
# File 'lib/syntax_tree/node.rb', line 8915
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8955
8956
8957
|
# File 'lib/syntax_tree/node.rb', line 8955
def ===(other)
other.is_a?(RationalLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
8926
8927
8928
|
# File 'lib/syntax_tree/node.rb', line 8926
def accept(visitor)
visitor.visit_rational(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8930
8931
8932
|
# File 'lib/syntax_tree/node.rb', line 8930
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
|
# File 'lib/syntax_tree/node.rb', line 8934
def copy(value: nil, location: nil)
node =
RationalLiteral.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
8947
8948
8949
|
# File 'lib/syntax_tree/node.rb', line 8947
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8951
8952
8953
|
# File 'lib/syntax_tree/node.rb', line 8951
def format(q)
q.text(value)
end
|