Class: SyntaxTree::RegexpContent
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
-
#beginning ⇒ Object
readonly
- String
-
the opening of the regular expression.
-
#parts ⇒ Object
readonly
- Array[ StringDVar | StringEmbExpr | TStringContent ]
-
the parts of the regular expression.
Attributes inherited from Node
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(beginning: nil, parts: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
-
#initialize(beginning:, parts:, location:) ⇒ RegexpContent
constructor
A new instance of RegexpContent.
Methods inherited from Node
#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(beginning:, parts:, location:) ⇒ RegexpContent
9088 9089 9090 9091 9092 |
# File 'lib/syntax_tree/node.rb', line 9088 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
9082 9083 9084 |
# File 'lib/syntax_tree/node.rb', line 9082 def beginning @beginning end |
#parts ⇒ Object (readonly)
- Array[ StringDVar | StringEmbExpr | TStringContent ]
-
the parts of the
regular expression
9086 9087 9088 |
# File 'lib/syntax_tree/node.rb', line 9086 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
9116 9117 9118 9119 |
# File 'lib/syntax_tree/node.rb', line 9116 def ===(other) other.is_a?(RegexpContent) && beginning === other.beginning && parts === other.parts end |
#accept(visitor) ⇒ Object
9094 9095 9096 |
# File 'lib/syntax_tree/node.rb', line 9094 def accept(visitor) visitor.visit_regexp_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9098 9099 9100 |
# File 'lib/syntax_tree/node.rb', line 9098 def child_nodes parts end |
#copy(beginning: nil, parts: nil, location: nil) ⇒ Object
9102 9103 9104 9105 9106 9107 9108 |
# File 'lib/syntax_tree/node.rb', line 9102 def copy(beginning: nil, parts: nil, location: nil) RegexpContent.new( beginning: beginning || self.beginning, parts: parts || self.parts, location: location || self.location ) end |
#deconstruct_keys(_keys) ⇒ Object
9112 9113 9114 |
# File 'lib/syntax_tree/node.rb', line 9112 def deconstruct_keys(_keys) { beginning: beginning, parts: parts, location: location } end |