Class: SyntaxTree::EmbExprBeg

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

Overview

EmbExprBeg represents the beginning token for using interpolation inside of a parent node that accepts string content (like a string or regular expression).

"Hello, #{person}!"

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:) ⇒ EmbExprBeg

Returns a new instance of EmbExprBeg.



5042
5043
5044
5045
# File 'lib/syntax_tree/node.rb', line 5042

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

Instance Attribute Details

#valueObject (readonly)

String

the #{ used in the string



5040
5041
5042
# File 'lib/syntax_tree/node.rb', line 5040

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



5068
5069
5070
# File 'lib/syntax_tree/node.rb', line 5068

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

#accept(visitor) ⇒ Object



5047
5048
5049
# File 'lib/syntax_tree/node.rb', line 5047

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

#child_nodesObject Also known as: deconstruct



5051
5052
5053
# File 'lib/syntax_tree/node.rb', line 5051

def child_nodes
  []
end

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



5055
5056
5057
5058
5059
5060
# File 'lib/syntax_tree/node.rb', line 5055

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

#deconstruct_keys(_keys) ⇒ Object



5064
5065
5066
# File 'lib/syntax_tree/node.rb', line 5064

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