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.
9073 9074 9075 9076 9077 |
# File 'lib/syntax_tree/node.rb', line 9073 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
9067 9068 9069 |
# File 'lib/syntax_tree/node.rb', line 9067 def beginning @beginning end |
#parts ⇒ Object (readonly)
- Array[ StringDVar | StringEmbExpr | TStringContent ]
-
the parts of the
regular expression
9071 9072 9073 |
# File 'lib/syntax_tree/node.rb', line 9071 def parts @parts end |
Instance Method Details
#===(other) ⇒ Object
9101 9102 9103 9104 |
# File 'lib/syntax_tree/node.rb', line 9101 def ===(other) other.is_a?(RegexpContent) && beginning === other.beginning && parts === other.parts end |
#accept(visitor) ⇒ Object
9079 9080 9081 |
# File 'lib/syntax_tree/node.rb', line 9079 def accept(visitor) visitor.visit_regexp_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9083 9084 9085 |
# File 'lib/syntax_tree/node.rb', line 9083 def child_nodes parts end |
#copy(beginning: nil, parts: nil, location: nil) ⇒ Object
9087 9088 9089 9090 9091 9092 9093 |
# File 'lib/syntax_tree/node.rb', line 9087 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
9097 9098 9099 |
# File 'lib/syntax_tree/node.rb', line 9097 def deconstruct_keys(_keys) { beginning: beginning, parts: parts, location: location } end |