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.



5617
5618
5619
5620
5621
# File 'lib/syntax_tree/node.rb', line 5617

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



5615
5616
5617
# File 'lib/syntax_tree/node.rb', line 5615

def comments
  @comments
end

#valueObject (readonly)

String

the value of the imaginary number literal



5612
5613
5614
# File 'lib/syntax_tree/node.rb', line 5612

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



5623
5624
5625
# File 'lib/syntax_tree/node.rb', line 5623

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

#child_nodesObject Also known as: deconstruct



5627
5628
5629
# File 'lib/syntax_tree/node.rb', line 5627

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



5633
5634
5635
# File 'lib/syntax_tree/node.rb', line 5633

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

#format(q) ⇒ Object



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

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