Class: SyntaxTree::Imaginary
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Imaginary
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:) ⇒ Imaginary
6569
6570
6571
6572
6573
|
# File 'lib/syntax_tree/node.rb', line 6569
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6567
6568
6569
|
# File 'lib/syntax_tree/node.rb', line 6567
def
@comments
end
|
#value ⇒ Object
- String
-
the value of the imaginary number literal
6564
6565
6566
|
# File 'lib/syntax_tree/node.rb', line 6564
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6604
6605
6606
|
# File 'lib/syntax_tree/node.rb', line 6604
def ===(other)
other.is_a?(Imaginary) && value === other.value
end
|
#accept(visitor) ⇒ Object
6575
6576
6577
|
# File 'lib/syntax_tree/node.rb', line 6575
def accept(visitor)
visitor.visit_imaginary(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6579
6580
6581
|
# File 'lib/syntax_tree/node.rb', line 6579
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
|
# File 'lib/syntax_tree/node.rb', line 6583
def copy(value: nil, location: nil)
node =
Imaginary.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
6596
6597
6598
|
# File 'lib/syntax_tree/node.rb', line 6596
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6600
6601
6602
|
# File 'lib/syntax_tree/node.rb', line 6600
def format(q)
q.text(value)
end
|