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.



7419
7420
7421
7422
7423
# File 'lib/syntax_tree/node.rb', line 7419

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

Instance Attribute Details

#beginningObject (readonly)

String

the opening of the regular expression



7413
7414
7415
# File 'lib/syntax_tree/node.rb', line 7413

def beginning
  @beginning
end

#partsObject (readonly)

Array[ StringDVar | StringEmbExpr | TStringContent ]

the parts of the

regular expression



7417
7418
7419
# File 'lib/syntax_tree/node.rb', line 7417

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



7425
7426
7427
# File 'lib/syntax_tree/node.rb', line 7425

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

#child_nodesObject Also known as: deconstruct



7429
7430
7431
# File 'lib/syntax_tree/node.rb', line 7429

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



7435
7436
7437
# File 'lib/syntax_tree/node.rb', line 7435

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