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.
8887
8888
8889
8890
8891
|
# File 'lib/syntax_tree/node.rb', line 8887
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8885
8886
8887
|
# File 'lib/syntax_tree/node.rb', line 8885
def
@comments
end
|
#value ⇒ Object
- String
-
the rational number literal
8882
8883
8884
|
# File 'lib/syntax_tree/node.rb', line 8882
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8922
8923
8924
|
# File 'lib/syntax_tree/node.rb', line 8922
def ===(other)
other.is_a?(RationalLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
8893
8894
8895
|
# File 'lib/syntax_tree/node.rb', line 8893
def accept(visitor)
visitor.visit_rational(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8897
8898
8899
|
# File 'lib/syntax_tree/node.rb', line 8897
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
|
# File 'lib/syntax_tree/node.rb', line 8901
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
8914
8915
8916
|
# File 'lib/syntax_tree/node.rb', line 8914
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8918
8919
8920
|
# File 'lib/syntax_tree/node.rb', line 8918
def format(q)
q.text(value)
end
|