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.
5368
5369
5370
5371
5372
|
# File 'lib/syntax_tree/node.rb', line 5368
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5366
5367
5368
|
# File 'lib/syntax_tree/node.rb', line 5366
def
@comments
end
|
#value ⇒ Object
- String
-
the value of the floating point number literal
5363
5364
5365
|
# File 'lib/syntax_tree/node.rb', line 5363
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5403
5404
5405
|
# File 'lib/syntax_tree/node.rb', line 5403
def ===(other)
other.is_a?(FloatLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
5374
5375
5376
|
# File 'lib/syntax_tree/node.rb', line 5374
def accept(visitor)
visitor.visit_float(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5378
5379
5380
|
# File 'lib/syntax_tree/node.rb', line 5378
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
|
# File 'lib/syntax_tree/node.rb', line 5382
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
5395
5396
5397
|
# File 'lib/syntax_tree/node.rb', line 5395
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5399
5400
5401
|
# File 'lib/syntax_tree/node.rb', line 5399
def format(q)
q.text(value)
end
|