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, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ Imaginary
6632
6633
6634
6635
6636
|
# File 'lib/syntax_tree/node.rb', line 6632
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6630
6631
6632
|
# File 'lib/syntax_tree/node.rb', line 6630
def
end
|
#value ⇒ Object
- String
-
the value of the imaginary number literal
6627
6628
6629
|
# File 'lib/syntax_tree/node.rb', line 6627
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6667
6668
6669
|
# File 'lib/syntax_tree/node.rb', line 6667
def ===(other)
other.is_a?(Imaginary) && value === other.value
end
|
#accept(visitor) ⇒ Object
6638
6639
6640
|
# File 'lib/syntax_tree/node.rb', line 6638
def accept(visitor)
visitor.visit_imaginary(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6642
6643
6644
|
# File 'lib/syntax_tree/node.rb', line 6642
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
|
# File 'lib/syntax_tree/node.rb', line 6646
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
6659
6660
6661
|
# File 'lib/syntax_tree/node.rb', line 6659
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6663
6664
6665
|
# File 'lib/syntax_tree/node.rb', line 6663
def format(q)
q.text(value)
end
|