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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ FloatLiteral
Returns a new instance of FloatLiteral.
5272
5273
5274
5275
5276
|
# File 'lib/syntax_tree/node.rb', line 5272
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5270
5271
5272
|
# File 'lib/syntax_tree/node.rb', line 5270
def
@comments
end
|
#value ⇒ Object
- String
-
the value of the floating point number literal
5267
5268
5269
|
# File 'lib/syntax_tree/node.rb', line 5267
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5307
5308
5309
|
# File 'lib/syntax_tree/node.rb', line 5307
def ===(other)
other.is_a?(FloatLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
5278
5279
5280
|
# File 'lib/syntax_tree/node.rb', line 5278
def accept(visitor)
visitor.visit_float(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5282
5283
5284
|
# File 'lib/syntax_tree/node.rb', line 5282
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
|
# File 'lib/syntax_tree/node.rb', line 5286
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
5299
5300
5301
|
# File 'lib/syntax_tree/node.rb', line 5299
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5303
5304
5305
|
# File 'lib/syntax_tree/node.rb', line 5303
def format(q)
q.text(value)
end
|