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.



7582
7583
7584
7585
7586
7587
7588
# File 'lib/prism/node.rb', line 7582

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.



7630
7631
7632
# File 'lib/prism/node.rb', line 7630

def value
  @value
end

Class Method Details

.typeObject

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



7643
7644
7645
# File 'lib/prism/node.rb', line 7643

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.



7649
7650
7651
7652
# File 'lib/prism/node.rb', line 7649

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



7591
7592
7593
# File 'lib/prism/node.rb', line 7591

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



7596
7597
7598
# File 'lib/prism/node.rb', line 7596

def child_nodes
  []
end

#comment_targetsObject

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



7612
7613
7614
# File 'lib/prism/node.rb', line 7612

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



7607
7608
7609
# File 'lib/prism/node.rb', line 7607

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



7617
7618
7619
# File 'lib/prism/node.rb', line 7617

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 }



7625
7626
7627
# File 'lib/prism/node.rb', line 7625

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

#each_child_nodeObject

def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator



7601
7602
7603
7604
# File 'lib/prism/node.rb', line 7601

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



7633
7634
7635
# File 'lib/prism/node.rb', line 7633

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



7638
7639
7640
# File 'lib/prism/node.rb', line 7638

def type
  :float_node
end