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

#format, #pretty_print, #to_json

Constructor Details

#initialize(beginning:, parts:, location:) ⇒ RegexpContent

Returns a new instance of RegexpContent.



6621
6622
6623
6624
6625
# File 'lib/syntax_tree/node.rb', line 6621

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

Instance Attribute Details

#beginningObject (readonly)

String

the opening of the regular expression



6615
6616
6617
# File 'lib/syntax_tree/node.rb', line 6615

def beginning
  @beginning
end

#partsObject (readonly)

Array[ StringDVar | StringEmbExpr | TStringContent ]

the parts of the

regular expression



6619
6620
6621
# File 'lib/syntax_tree/node.rb', line 6619

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



6627
6628
6629
# File 'lib/syntax_tree/node.rb', line 6627

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

#child_nodesObject Also known as: deconstruct



6631
6632
6633
# File 'lib/syntax_tree/node.rb', line 6631

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



6637
6638
6639
# File 'lib/syntax_tree/node.rb', line 6637

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