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, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ TLambda



10604
10605
10606
10607
# File 'lib/syntax_tree/node.rb', line 10604

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the lambda literal



10602
10603
10604
# File 'lib/syntax_tree/node.rb', line 10602

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10630
10631
10632
# File 'lib/syntax_tree/node.rb', line 10630

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

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



10613
10614
10615
# File 'lib/syntax_tree/node.rb', line 10613

def child_nodes
  []
end

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



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

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

#deconstruct_keys(_keys) ⇒ Object



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

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