Class: SyntaxTree::FloatLiteral
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::FloatLiteral
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
FloatLiteral represents a floating point number literal.
1.0
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the value of the floating point number literal.
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:) ⇒ FloatLiteral
Returns a new instance of FloatLiteral.
5386
5387
5388
5389
5390
|
# File 'lib/syntax_tree/node.rb', line 5386
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5384
5385
5386
|
# File 'lib/syntax_tree/node.rb', line 5384
def
end
|
#value ⇒ Object
- String
-
the value of the floating point number literal
5381
5382
5383
|
# File 'lib/syntax_tree/node.rb', line 5381
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5421
5422
5423
|
# File 'lib/syntax_tree/node.rb', line 5421
def ===(other)
other.is_a?(FloatLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
5392
5393
5394
|
# File 'lib/syntax_tree/node.rb', line 5392
def accept(visitor)
visitor.visit_float(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5396
5397
5398
|
# File 'lib/syntax_tree/node.rb', line 5396
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
|
# File 'lib/syntax_tree/node.rb', line 5400
def copy(value: nil, location: nil)
node =
FloatLiteral.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
5413
5414
5415
|
# File 'lib/syntax_tree/node.rb', line 5413
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5417
5418
5419
|
# File 'lib/syntax_tree/node.rb', line 5417
def format(q)
q.text(value)
end
|