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.
6663
6664
6665
6666
6667
|
# File 'lib/syntax_tree/node.rb', line 6663
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6661
6662
6663
|
# File 'lib/syntax_tree/node.rb', line 6661
def
end
|
#value ⇒ Object
- String
-
the value of the imaginary number literal
6658
6659
6660
|
# File 'lib/syntax_tree/node.rb', line 6658
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6698
6699
6700
|
# File 'lib/syntax_tree/node.rb', line 6698
def ===(other)
other.is_a?(Imaginary) && value === other.value
end
|
#accept(visitor) ⇒ Object
6669
6670
6671
|
# File 'lib/syntax_tree/node.rb', line 6669
def accept(visitor)
visitor.visit_imaginary(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6673
6674
6675
|
# File 'lib/syntax_tree/node.rb', line 6673
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
|
# File 'lib/syntax_tree/node.rb', line 6677
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
6690
6691
6692
|
# File 'lib/syntax_tree/node.rb', line 6690
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6694
6695
6696
|
# File 'lib/syntax_tree/node.rb', line 6694
def format(q)
q.text(value)
end
|