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.
8856
8857
8858
8859
8860
|
# File 'lib/syntax_tree/node.rb', line 8856
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8854
8855
8856
|
# File 'lib/syntax_tree/node.rb', line 8854
def
@comments
end
|
#value ⇒ Object
- String
-
the rational number literal
8851
8852
8853
|
# File 'lib/syntax_tree/node.rb', line 8851
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8891
8892
8893
|
# File 'lib/syntax_tree/node.rb', line 8891
def ===(other)
other.is_a?(RationalLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
8862
8863
8864
|
# File 'lib/syntax_tree/node.rb', line 8862
def accept(visitor)
visitor.visit_rational(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8866
8867
8868
|
# File 'lib/syntax_tree/node.rb', line 8866
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
|
# File 'lib/syntax_tree/node.rb', line 8870
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
8883
8884
8885
|
# File 'lib/syntax_tree/node.rb', line 8883
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8887
8888
8889
|
# File 'lib/syntax_tree/node.rb', line 8887
def format(q)
q.text(value)
end
|