Class: SyntaxTree::TLambda

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

Overview

TLambda represents the beginning of a lambda literal.

-> { value }

In the example above the TLambda represents 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:) ⇒ TLambda

Returns a new instance of TLambda.



10745
10746
10747
10748
# File 'lib/syntax_tree/node.rb', line 10745

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the lambda literal



10743
10744
10745
# File 'lib/syntax_tree/node.rb', line 10743

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10771
10772
10773
# File 'lib/syntax_tree/node.rb', line 10771

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

#accept(visitor) ⇒ Object



10750
10751
10752
# File 'lib/syntax_tree/node.rb', line 10750

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

#child_nodesObject Also known as: deconstruct



10754
10755
10756
# File 'lib/syntax_tree/node.rb', line 10754

def child_nodes
  []
end

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



10758
10759
10760
10761
10762
10763
# File 'lib/syntax_tree/node.rb', line 10758

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

#deconstruct_keys(_keys) ⇒ Object



10767
10768
10769
# File 'lib/syntax_tree/node.rb', line 10767

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