Class: Prism::FloatNode

Inherits:
PrismNode
  • Object
show all
Defined in:
lib/prism/node.rb,
ext/prism/api_node.c

Overview

Represents a floating point number literal.

1.0
^^^

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, value) ⇒ FloatNode

Initialize a new FloatNode node.



6165
6166
6167
6168
6169
6170
6171
# File 'lib/prism/node.rb', line 6165

def initialize(source, node_id, location, flags, value)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

The value of the floating point number as a Float.



6207
6208
6209
# File 'lib/prism/node.rb', line 6207

def value
  @value
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



6220
6221
6222
# File 'lib/prism/node.rb', line 6220

def self.type
  :float_node
end

Instance Method Details

#===(other) ⇒ Object

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.



6226
6227
6228
6229
# File 'lib/prism/node.rb', line 6226

def ===(other)
  other.is_a?(FloatNode) &&
    (value === other.value)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



6174
6175
6176
# File 'lib/prism/node.rb', line 6174

def accept(visitor)
  visitor.visit_float_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



6179
6180
6181
# File 'lib/prism/node.rb', line 6179

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



6189
6190
6191
# File 'lib/prism/node.rb', line 6189

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



6184
6185
6186
# File 'lib/prism/node.rb', line 6184

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode



6194
6195
6196
# File 'lib/prism/node.rb', line 6194

def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value)
  FloatNode.new(source, node_id, location, flags, value)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Float }



6202
6203
6204
# File 'lib/prism/node.rb', line 6202

def deconstruct_keys(keys)
  { node_id: node_id, location: location, value: value }
end

#inspectObject

def inspect -> String



6210
6211
6212
# File 'lib/prism/node.rb', line 6210

def inspect
  InspectVisitor.compose(self)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



6215
6216
6217
# File 'lib/prism/node.rb', line 6215

def type
  :float_node
end