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
Returns a new instance of Imaginary.
6702
6703
6704
6705
6706
|
# File 'lib/syntax_tree/node.rb', line 6702
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6700
6701
6702
|
# File 'lib/syntax_tree/node.rb', line 6700
def
@comments
end
|
#value ⇒ Object
- String
-
the value of the imaginary number literal
6697
6698
6699
|
# File 'lib/syntax_tree/node.rb', line 6697
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6737
6738
6739
|
# File 'lib/syntax_tree/node.rb', line 6737
def ===(other)
other.is_a?(Imaginary) && value === other.value
end
|
#accept(visitor) ⇒ Object
6708
6709
6710
|
# File 'lib/syntax_tree/node.rb', line 6708
def accept(visitor)
visitor.visit_imaginary(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6712
6713
6714
|
# File 'lib/syntax_tree/node.rb', line 6712
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
|
# File 'lib/syntax_tree/node.rb', line 6716
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
6729
6730
6731
|
# File 'lib/syntax_tree/node.rb', line 6729
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6733
6734
6735
|
# File 'lib/syntax_tree/node.rb', line 6733
def format(q)
q.text(value)
end
|