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
Returns a new instance of RegexpContent.
9025 9026 9027 9028 9029 |
# File 'lib/syntax_tree/node.rb', line 9025 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
9019 9020 9021 |
# File 'lib/syntax_tree/node.rb', line 9019 def beginning @beginning end |
#parts ⇒ Object (readonly)
- Array[ StringDVar | StringEmbExpr | TStringContent ]
-
the parts of the
regular expression
9023 9024 9025 |
# File 'lib/syntax_tree/node.rb', line 9023 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
9053 9054 9055 9056 |
# File 'lib/syntax_tree/node.rb', line 9053 def ===(other) other.is_a?(RegexpContent) && beginning === other.beginning && parts === other.parts end |
#accept(visitor) ⇒ Object
9031 9032 9033 |
# File 'lib/syntax_tree/node.rb', line 9031 def accept(visitor) visitor.visit_regexp_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9035 9036 9037 |
# File 'lib/syntax_tree/node.rb', line 9035 def child_nodes parts end |
#copy(beginning: nil, parts: nil, location: nil) ⇒ Object
9039 9040 9041 9042 9043 9044 9045 |
# File 'lib/syntax_tree/node.rb', line 9039 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
9049 9050 9051 |
# File 'lib/syntax_tree/node.rb', line 9049 def deconstruct_keys(_keys) { beginning: beginning, parts: parts, location: location } end |