class YARP::ImaginaryNode

Represents an imaginary number literal.

1.0i
^^^^

Attributes

numeric[R]

attr_reader numeric: Node

Public Class Methods

new(numeric, location) click to toggle source

def initialize: (numeric: Node, location: Location) -> void

# File yarp/node.rb, line 5276
def initialize(numeric, location)
  @numeric = numeric
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

# File yarp/node.rb, line 5282
def accept(visitor)
  visitor.visit_imaginary_node(self)
end
child_nodes() click to toggle source

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

# File yarp/node.rb, line 5287
def child_nodes
  [numeric]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

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

# File yarp/node.rb, line 5292
def comment_targets
  [numeric]
end
copy(**params) click to toggle source

def copy: (**params) -> ImaginaryNode

# File yarp/node.rb, line 5297
def copy(**params)
  ImaginaryNode.new(
    params.fetch(:numeric) { numeric },
    params.fetch(:location) { location },
  )
end
deconstruct()

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

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]

# File yarp/node.rb, line 5308
def deconstruct_keys(keys)
  { numeric: numeric, location: location }
end
inspect(inspector = NodeInspector.new) click to toggle source
# File yarp/node.rb, line 5312
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "└── numeric:\n"
  inspector << inspector.child_node(numeric, "    ")
  inspector.to_str
end
value() click to toggle source

Returns the value of the node as a Ruby Complex.

# File yarp.rb, line 580
def value
  Complex(0, numeric.value)
end