Class: SyntaxTree::EmbExprEnd

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

Overview

EmbExprEnd represents the ending 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, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ EmbExprEnd

Returns a new instance of EmbExprEnd.



4976
4977
4978
4979
# File 'lib/syntax_tree/node.rb', line 4976

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

Instance Attribute Details

#valueObject (readonly)

String

the } used in the string



4974
4975
4976
# File 'lib/syntax_tree/node.rb', line 4974

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



5002
5003
5004
# File 'lib/syntax_tree/node.rb', line 5002

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

#accept(visitor) ⇒ Object



4981
4982
4983
# File 'lib/syntax_tree/node.rb', line 4981

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

#child_nodesObject Also known as: deconstruct



4985
4986
4987
# File 'lib/syntax_tree/node.rb', line 4985

def child_nodes
  []
end

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



4989
4990
4991
4992
4993
4994
# File 'lib/syntax_tree/node.rb', line 4989

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

#deconstruct_keys(_keys) ⇒ Object



4998
4999
5000
# File 'lib/syntax_tree/node.rb', line 4998

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