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