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



7467
7468
7469
7470
# File 'lib/syntax_tree/node.rb', line 7467

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the regular expression



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

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7472
7473
7474
# File 'lib/syntax_tree/node.rb', line 7472

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

#child_nodesObject Also known as: deconstruct



7476
7477
7478
# File 'lib/syntax_tree/node.rb', line 7476

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



7482
7483
7484
# File 'lib/syntax_tree/node.rb', line 7482

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