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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ RationalLiteral
8765
8766
8767
8768
8769
|
# File 'lib/syntax_tree/node.rb', line 8765
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8763
8764
8765
|
# File 'lib/syntax_tree/node.rb', line 8763
def
end
|
#value ⇒ Object
- String
-
the rational number literal
8760
8761
8762
|
# File 'lib/syntax_tree/node.rb', line 8760
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8800
8801
8802
|
# File 'lib/syntax_tree/node.rb', line 8800
def ===(other)
other.is_a?(RationalLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
8771
8772
8773
|
# File 'lib/syntax_tree/node.rb', line 8771
def accept(visitor)
visitor.visit_rational(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8775
8776
8777
|
# File 'lib/syntax_tree/node.rb', line 8775
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
|
# File 'lib/syntax_tree/node.rb', line 8779
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
8792
8793
8794
|
# File 'lib/syntax_tree/node.rb', line 8792
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8796
8797
8798
|
# File 'lib/syntax_tree/node.rb', line 8796
def format(q)
q.text(value)
end
|