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
Returns a new instance of RationalLiteral.
8756
8757
8758
8759
8760
|
# File 'lib/syntax_tree/node.rb', line 8756
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8754
8755
8756
|
# File 'lib/syntax_tree/node.rb', line 8754
def
@comments
end
|
#value ⇒ Object
- String
-
the rational number literal
8751
8752
8753
|
# File 'lib/syntax_tree/node.rb', line 8751
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8791
8792
8793
|
# File 'lib/syntax_tree/node.rb', line 8791
def ===(other)
other.is_a?(RationalLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
8762
8763
8764
|
# File 'lib/syntax_tree/node.rb', line 8762
def accept(visitor)
visitor.visit_rational(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8766
8767
8768
|
# File 'lib/syntax_tree/node.rb', line 8766
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
|
# File 'lib/syntax_tree/node.rb', line 8770
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
8783
8784
8785
|
# File 'lib/syntax_tree/node.rb', line 8783
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8787
8788
8789
|
# File 'lib/syntax_tree/node.rb', line 8787
def format(q)
q.text(value)
end
|