Class: SyntaxTree::TLamBeg

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

Overview

TLamBeg represents the beginning of the body of a lambda literal using braces.

-> { value }

In the example above the TLamBeg represents the { operator.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ TLamBeg

Returns a new instance of TLamBeg.



10610
10611
10612
10613
# File 'lib/syntax_tree/node.rb', line 10610

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the body of the lambda literal



10608
10609
10610
# File 'lib/syntax_tree/node.rb', line 10608

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10636
10637
10638
# File 'lib/syntax_tree/node.rb', line 10636

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

#accept(visitor) ⇒ Object



10615
10616
10617
# File 'lib/syntax_tree/node.rb', line 10615

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

#child_nodesObject Also known as: deconstruct



10619
10620
10621
# File 'lib/syntax_tree/node.rb', line 10619

def child_nodes
  []
end

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



10623
10624
10625
10626
10627
10628
# File 'lib/syntax_tree/node.rb', line 10623

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

#deconstruct_keys(_keys) ⇒ Object



10632
10633
10634
# File 'lib/syntax_tree/node.rb', line 10632

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