Class: SyntaxTree::EmbVar

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

Overview

EmbVar represents the use of shorthand interpolation for an instance, class, or global variable into a parent node that accepts string content (like a string or regular expression).

"#@variable"

In the example above, an EmbVar node represents the # because it forces

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

Returns a new instance of EmbVar.



4264
4265
4266
4267
# File 'lib/syntax_tree/node.rb', line 4264

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

Instance Attribute Details

#valueObject (readonly)

String

the # used in the string



4262
4263
4264
# File 'lib/syntax_tree/node.rb', line 4262

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



4269
4270
4271
# File 'lib/syntax_tree/node.rb', line 4269

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

#child_nodesObject Also known as: deconstruct



4273
4274
4275
# File 'lib/syntax_tree/node.rb', line 4273

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



4279
4280
4281
# File 'lib/syntax_tree/node.rb', line 4279

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