Class: SyntaxTree::RegexpBeg

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

Overview

RegexpBeg represents the start of a regular expression literal.

/.+/

In the example above, RegexpBeg represents the first / token. Regular expression literals can also be declared using the %r syntax, as in:

%r{.+}

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

Returns a new instance of RegexpBeg.



7450
7451
7452
7453
# File 'lib/syntax_tree/node.rb', line 7450

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the regular expression



7448
7449
7450
# File 'lib/syntax_tree/node.rb', line 7448

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7455
7456
7457
# File 'lib/syntax_tree/node.rb', line 7455

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

#child_nodesObject Also known as: deconstruct



7459
7460
7461
# File 'lib/syntax_tree/node.rb', line 7459

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



7465
7466
7467
# File 'lib/syntax_tree/node.rb', line 7465

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