Class: Cucumber::CucumberExpressions::TreeRegexp

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/tree_regexp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp) ⇒ TreeRegexp

Returns a new instance of TreeRegexp.



9
10
11
12
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/tree_regexp.rb', line 9

def initialize(regexp)
  @regexp = regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp)
  @group_builder = create_group_builder(@regexp)
end

Instance Attribute Details

#group_builderObject (readonly)

Returns the value of attribute group_builder.



7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/tree_regexp.rb', line 7

def group_builder
  @group_builder
end

#regexpObject (readonly)

Returns the value of attribute regexp.



7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/tree_regexp.rb', line 7

def regexp
  @regexp
end

Instance Method Details

#match(s) ⇒ Object



14
15
16
17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/tree_regexp.rb', line 14

def match(s)
  match = @regexp.match(s)
  return nil if match.nil?
  group_indices = (0..match.length).to_a.to_enum
  @group_builder.build(match, group_indices)
end