Class: Prism::ImaginaryNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ImaginaryNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
ext/prism/api_node.c
Overview
Represents an imaginary number literal.
1.0i
^^^^
Instance Attribute Summary collapse
-
#numeric ⇒ Object
readonly
attr_reader numeric: FloatNode | IntegerNode | RationalNode.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, numeric: self.numeric) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: FloatNode | IntegerNode | RationalNode) -> ImaginaryNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, numeric: FloatNode | IntegerNode | RationalNode }.
-
#initialize(source, node_id, location, flags, numeric) ⇒ ImaginaryNode
constructor
Initialize a new ImaginaryNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#type ⇒ Object
Return a symbol representation of this node type.
-
#value ⇒ Object
Returns the value of the node as a Ruby Complex.
Constructor Details
#initialize(source, node_id, location, flags, numeric) ⇒ ImaginaryNode
Initialize a new ImaginaryNode node.
8760 8761 8762 8763 8764 8765 8766 |
# File 'lib/prism/node.rb', line 8760 def initialize(source, node_id, location, flags, numeric) @source = source @node_id = node_id @location = location @flags = flags @numeric = numeric end |
Instance Attribute Details
#numeric ⇒ Object (readonly)
attr_reader numeric: FloatNode | IntegerNode | RationalNode
8802 8803 8804 |
# File 'lib/prism/node.rb', line 8802 def numeric @numeric end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
8815 8816 8817 |
# File 'lib/prism/node.rb', line 8815 def self.type :imaginary_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.
8821 8822 8823 8824 |
# File 'lib/prism/node.rb', line 8821 def ===(other) other.is_a?(ImaginaryNode) && (numeric === other.numeric) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
8769 8770 8771 |
# File 'lib/prism/node.rb', line 8769 def accept(visitor) visitor.visit_imaginary_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
8774 8775 8776 |
# File 'lib/prism/node.rb', line 8774 def child_nodes [numeric] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
8784 8785 8786 |
# File 'lib/prism/node.rb', line 8784 def comment_targets [numeric] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
8779 8780 8781 |
# File 'lib/prism/node.rb', line 8779 def compact_child_nodes [numeric] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, numeric: self.numeric) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: FloatNode | IntegerNode | RationalNode) -> ImaginaryNode
8789 8790 8791 |
# File 'lib/prism/node.rb', line 8789 def copy(node_id: self.node_id, location: self.location, flags: self.flags, numeric: self.numeric) ImaginaryNode.new(source, node_id, location, flags, numeric) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, numeric: FloatNode | IntegerNode | RationalNode }
8797 8798 8799 |
# File 'lib/prism/node.rb', line 8797 def deconstruct_keys(keys) { node_id: node_id, location: location, numeric: numeric } end |
#inspect ⇒ Object
def inspect -> String
8805 8806 8807 |
# File 'lib/prism/node.rb', line 8805 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
8810 8811 8812 |
# File 'lib/prism/node.rb', line 8810 def type :imaginary_node end |
#value ⇒ Object
Returns the value of the node as a Ruby Complex.
110 111 112 |
# File 'lib/prism/node_ext.rb', line 110 def value Complex(0, numeric.value) end |