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.



6202
6203
6204
6205
6206
6207
6208
# File 'lib/prism/node.rb', line 6202

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.



6244
6245
6246
# File 'lib/prism/node.rb', line 6244

def value
  @value
end

Class Method Details

.typeObject

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



6257
6258
6259
# File 'lib/prism/node.rb', line 6257

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.



6263
6264
6265
6266
# File 'lib/prism/node.rb', line 6263

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  []
end

#comment_targetsObject

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



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

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



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

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



6231
6232
6233
# File 'lib/prism/node.rb', line 6231

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 }



6239
6240
6241
# File 'lib/prism/node.rb', line 6239

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

#inspectObject

def inspect -> String



6247
6248
6249
# File 'lib/prism/node.rb', line 6247

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



6252
6253
6254
# File 'lib/prism/node.rb', line 6252

def type
  :float_node
end