Class: SyntaxTree::Comma

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Comma represents the use of the , operator.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(value:, location:) ⇒ Comma

Returns a new instance of Comma.



3405
3406
3407
3408
# File 'lib/syntax_tree/node.rb', line 3405

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#valueObject (readonly)

String

the comma in the string



3403
3404
3405
# File 'lib/syntax_tree/node.rb', line 3403

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



3428
3429
3430
# File 'lib/syntax_tree/node.rb', line 3428

def ===(other)
  other.is_a?(Comma) && value === other.value
end

#accept(visitor) ⇒ Object



3410
3411
3412
# File 'lib/syntax_tree/node.rb', line 3410

def accept(visitor)
  visitor.visit_comma(self)
end

#child_nodesObject Also known as: deconstruct



3414
3415
3416
# File 'lib/syntax_tree/node.rb', line 3414

def child_nodes
  []
end

#copy(value: nil, location: nil) ⇒ Object



3418
3419
3420
# File 'lib/syntax_tree/node.rb', line 3418

def copy(value: nil, location: nil)
  Comma.new(value: value || self.value, location: location || self.location)
end

#deconstruct_keys(_keys) ⇒ Object



3424
3425
3426
# File 'lib/syntax_tree/node.rb', line 3424

def deconstruct_keys(_keys)
  { value: value, location: location }
end