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.
5263
5264
5265
5266
5267
|
# File 'lib/syntax_tree/node.rb', line 5263
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5261
5262
5263
|
# File 'lib/syntax_tree/node.rb', line 5261
def
@comments
end
|
#value ⇒ Object
- String
-
the value of the floating point number literal
5258
5259
5260
|
# File 'lib/syntax_tree/node.rb', line 5258
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5298
5299
5300
|
# File 'lib/syntax_tree/node.rb', line 5298
def ===(other)
other.is_a?(FloatLiteral) && value === other.value
end
|
#accept(visitor) ⇒ Object
5269
5270
5271
|
# File 'lib/syntax_tree/node.rb', line 5269
def accept(visitor)
visitor.visit_float(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5273
5274
5275
|
# File 'lib/syntax_tree/node.rb', line 5273
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
|
# File 'lib/syntax_tree/node.rb', line 5277
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
5290
5291
5292
|
# File 'lib/syntax_tree/node.rb', line 5290
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5294
5295
5296
|
# File 'lib/syntax_tree/node.rb', line 5294
def format(q)
q.text(value)
end
|