Class: Prism::ImaginaryNode
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
PrismNode
|
|
|
Instance Chain:
self,
PrismNode
|
|
| Inherits: |
PrismNode
|
| Defined in: | lib/prism/node.rb, ext/prism/api_node.c, lib/prism/node_ext.rb |
Overview
Represents an imaginary number literal.
1.0i
^^^^
Class Method Summary
-
.new(source, node_id, location, flags, numeric) ⇒ ImaginaryNode
constructor
Initialize a new
ImaginaryNodenode. -
.type
Return a symbol representation of this node type.
Instance Attribute Summary
-
#numeric
readonly
attr_reader numeric:
FloatNode|IntegerNode|RationalNode.
Instance Method Summary
-
#===(other)
Implements case-equality for the node.
-
#accept(visitor)
def accept: (Visitor visitor) -> void.
-
#child_nodes
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, numeric: self.numeric)
def copy: (?node_id: Integer, ?location:
Location, ?flags: Integer, ?numeric:FloatNode|IntegerNode|RationalNode) ->ImaginaryNode. -
#deconstruct
Alias for #child_nodes.
-
#deconstruct_keys(keys)
def deconstruct_keys: (Array keys) -> { node_id: Integer, location:
Location, numeric:FloatNode|IntegerNode|RationalNode} -
#inspect
def inspect -> String.
-
#type
Return a symbol representation of this node type.
-
#value
Returns the value of the node as a Ruby Complex.
Constructor Details
.new(source, node_id, location, flags, numeric) ⇒ ImaginaryNode
Initialize a new ImaginaryNode node.
Class Method Details
.type
Return a symbol representation of this node type. See Node::type.
# File 'lib/prism/node.rb', line 7550
def self.type :imaginary_node end
Instance Attribute Details
#numeric (readonly)
attr_reader numeric: FloatNode | IntegerNode | RationalNode
# File 'lib/prism/node.rb', line 7538
attr_reader :numeric
Instance Method Details
#===(other)
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
#accept(visitor)
def accept: (Visitor visitor) -> void
# File 'lib/prism/node.rb', line 7505
def accept(visitor) visitor.visit_imaginary_node(self) end
#child_nodes Also known as: #deconstruct
def child_nodes: () -> Array[nil | Node]
# File 'lib/prism/node.rb', line 7510
def child_nodes [numeric] end
#comment_targets
def comment_targets: () -> Array[Node | Location]
# File 'lib/prism/node.rb', line 7520
def comment_targets [numeric] #: Array[Prism::node | Location] end
#compact_child_nodes
def compact_child_nodes: () -> Array
# File 'lib/prism/node.rb', line 7515
def compact_child_nodes [numeric] end
#copy(node_id: self.node_id, location: self.location, flags: self.flags, numeric: self.numeric)
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: FloatNode | IntegerNode | RationalNode) -> ImaginaryNode
#deconstruct
Alias for #child_nodes.
# File 'lib/prism/node.rb', line 7530
alias deconstruct child_nodes
#deconstruct_keys(keys)
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, numeric: FloatNode | IntegerNode | RationalNode }
# File 'lib/prism/node.rb', line 7533
def deconstruct_keys(keys) { node_id: node_id, location: location, numeric: numeric } end
#inspect
def inspect -> String
# File 'lib/prism/node.rb', line 7540
def inspect InspectVisitor.compose(self) end
#type
Return a symbol representation of this node type. See Node#type.
# File 'lib/prism/node.rb', line 7545
def type :imaginary_node end
#value
Returns the value of the node as a Ruby Complex.
# File 'lib/prism/node_ext.rb', line 110
def value Complex(0, numeric.value) end