Class: SyntaxTree::Imaginary

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Imaginary represents an imaginary number literal.

1i

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ Imaginary

Returns a new instance of Imaginary.



5641
5642
5643
5644
5645
# File 'lib/syntax_tree/node.rb', line 5641

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



5639
5640
5641
# File 'lib/syntax_tree/node.rb', line 5639

def comments
  @comments
end

#valueObject (readonly)

String

the value of the imaginary number literal



5636
5637
5638
# File 'lib/syntax_tree/node.rb', line 5636

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



5647
5648
5649
# File 'lib/syntax_tree/node.rb', line 5647

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

#child_nodesObject Also known as: deconstruct



5651
5652
5653
# File 'lib/syntax_tree/node.rb', line 5651

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



5657
5658
5659
# File 'lib/syntax_tree/node.rb', line 5657

def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



5661
5662
5663
# File 'lib/syntax_tree/node.rb', line 5661

def format(q)
  q.text(value)
end