Class: Strling::Core::Group
Overview
Represents a capturing or non-capturing group.
Groups pattern elements together and optionally captures the matched text for later reference.
Instance Attribute Summary collapse
-
#atomic ⇒ Boolean?
Whether the group is atomic (extension).
-
#body ⇒ Node
The body of the group.
-
#capturing ⇒ Boolean
Whether the group is capturing.
-
#name ⇒ String?
The name of the group (for named captures).
Instance Method Summary collapse
-
#initialize(capturing, body, name: nil, atomic: nil) ⇒ Group
constructor
A new instance of Group.
- #to_dict ⇒ Object
Constructor Details
#initialize(capturing, body, name: nil, atomic: nil) ⇒ Group
Returns a new instance of Group.
367 368 369 370 371 372 |
# File 'lib/strling/core/nodes.rb', line 367 def initialize(capturing, body, name: nil, atomic: nil) @capturing = capturing @body = body @name = name @atomic = atomic end |
Instance Attribute Details
#atomic ⇒ Boolean?
Returns Whether the group is atomic (extension).
361 362 363 |
# File 'lib/strling/core/nodes.rb', line 361 def atomic @atomic end |
#body ⇒ Node
Returns The body of the group.
355 356 357 |
# File 'lib/strling/core/nodes.rb', line 355 def body @body end |
#capturing ⇒ Boolean
Returns Whether the group is capturing.
352 353 354 |
# File 'lib/strling/core/nodes.rb', line 352 def capturing @capturing end |
#name ⇒ String?
Returns The name of the group (for named captures).
358 359 360 |
# File 'lib/strling/core/nodes.rb', line 358 def name @name end |
Instance Method Details
#to_dict ⇒ Object
374 375 376 377 378 379 380 381 382 383 |
# File 'lib/strling/core/nodes.rb', line 374 def to_dict data = { 'kind' => 'Group', 'capturing' => capturing, 'body' => body.to_dict } data['name'] = name unless name.nil? data['atomic'] = atomic unless atomic.nil? data end |