Class: SyntaxTree::RegexpContent

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

Overview

RegexpContent represents the body of a regular expression.

/.+ #{pattern} .+/

In the example above, a RegexpContent node represents everything contained within the forward slashes.

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(beginning:, parts:, location:) ⇒ RegexpContent

Returns a new instance of RegexpContent.



7366
7367
7368
7369
7370
# File 'lib/syntax_tree/node.rb', line 7366

def initialize(beginning:, parts:, location:)
  @beginning = beginning
  @parts = parts
  @location = location
end

Instance Attribute Details

#beginning ⇒ Object (readonly)

[String] the opening of the regular expression



7360
7361
7362
# File 'lib/syntax_tree/node.rb', line 7360

def beginning
  @beginning
end

#parts ⇒ Object (readonly)

[Array[ StringDVar | StringEmbExpr | TStringContent ]] the parts of the regular expression



7364
7365
7366
# File 'lib/syntax_tree/node.rb', line 7364

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



7372
7373
7374
# File 'lib/syntax_tree/node.rb', line 7372

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

#child_nodes ⇒ Object Also known as: deconstruct



7376
7377
7378
# File 'lib/syntax_tree/node.rb', line 7376

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



7382
7383
7384
# File 'lib/syntax_tree/node.rb', line 7382

def deconstruct_keys(_keys)
  { beginning: beginning, parts: parts, location: location }
end