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.
6684
6685
6686
6687
6688
|
# File 'lib/syntax_tree/node.rb', line 6684
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6682
6683
6684
|
# File 'lib/syntax_tree/node.rb', line 6682
def
@comments
end
|
#value ⇒ Object
- String
-
the value of the imaginary number literal
6679
6680
6681
|
# File 'lib/syntax_tree/node.rb', line 6679
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6719
6720
6721
|
# File 'lib/syntax_tree/node.rb', line 6719
def ===(other)
other.is_a?(Imaginary) && value === other.value
end
|
#accept(visitor) ⇒ Object
6690
6691
6692
|
# File 'lib/syntax_tree/node.rb', line 6690
def accept(visitor)
visitor.visit_imaginary(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6694
6695
6696
|
# File 'lib/syntax_tree/node.rb', line 6694
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
|
# File 'lib/syntax_tree/node.rb', line 6698
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
6711
6712
6713
|
# File 'lib/syntax_tree/node.rb', line 6711
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6715
6716
6717
|
# File 'lib/syntax_tree/node.rb', line 6715
def format(q)
q.text(value)
end
|