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.



7169
7170
7171
7172
7173
7174
7175
# File 'lib/prism/node.rb', line 7169

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.



7211
7212
7213
# File 'lib/prism/node.rb', line 7211

def value
  @value
end

Class Method Details

.typeObject

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



7224
7225
7226
# File 'lib/prism/node.rb', line 7224

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.



7230
7231
7232
7233
# File 'lib/prism/node.rb', line 7230

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



7178
7179
7180
# File 'lib/prism/node.rb', line 7178

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



7183
7184
7185
# File 'lib/prism/node.rb', line 7183

def child_nodes
  []
end

#comment_targetsObject

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



7193
7194
7195
# File 'lib/prism/node.rb', line 7193

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



7188
7189
7190
# File 'lib/prism/node.rb', line 7188

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



7198
7199
7200
# File 'lib/prism/node.rb', line 7198

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 }



7206
7207
7208
# File 'lib/prism/node.rb', line 7206

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

#inspectObject

def inspect -> String



7214
7215
7216
# File 'lib/prism/node.rb', line 7214

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



7219
7220
7221
# File 'lib/prism/node.rb', line 7219

def type
  :float_node
end