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.



7289
7290
7291
7292
# File 'lib/syntax_tree/node.rb', line 7289

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the regular expression



7287
7288
7289
# File 'lib/syntax_tree/node.rb', line 7287

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7294
7295
7296
# File 'lib/syntax_tree/node.rb', line 7294

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

#child_nodesObject Also known as: deconstruct



7298
7299
7300
# File 'lib/syntax_tree/node.rb', line 7298

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



7304
7305
7306
# File 'lib/syntax_tree/node.rb', line 7304

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