Class: YARP::EmbeddedVariableNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents an interpolated variable.

"foo #@bar"
     ^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator_loc, variable, location) ⇒ EmbeddedVariableNode

def initialize: (operator_loc: Location, variable: Node, location: Location) -> void



2723
2724
2725
2726
2727
# File 'lib/yarp/node.rb', line 2723

def initialize(operator_loc, variable, location)
  @operator_loc = operator_loc
  @variable = variable
  @location = location
end

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



2717
2718
2719
# File 'lib/yarp/node.rb', line 2717

def operator_loc
  @operator_loc
end

#variableObject (readonly)

attr_reader variable: Node



2720
2721
2722
# File 'lib/yarp/node.rb', line 2720

def variable
  @variable
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2730
2731
2732
# File 'lib/yarp/node.rb', line 2730

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



2735
2736
2737
# File 'lib/yarp/node.rb', line 2735

def child_nodes
  [variable]
end

#copy(**params) ⇒ Object

def copy: (**params) -> EmbeddedVariableNode



2740
2741
2742
2743
2744
2745
2746
# File 'lib/yarp/node.rb', line 2740

def copy(**params)
  EmbeddedVariableNode.new(
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:variable) { variable },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



2752
2753
2754
# File 'lib/yarp/node.rb', line 2752

def deconstruct_keys(keys)
  { operator_loc: operator_loc, variable: variable, location: location }
end

#operatorObject

def operator: () -> String



2757
2758
2759
# File 'lib/yarp/node.rb', line 2757

def operator
  operator_loc.slice
end