Class: Cucumber::CucumberExpressions::TreeRegexp
- Inherits:
-
Object
- Object
- Cucumber::CucumberExpressions::TreeRegexp
- Defined in:
- lib/cucumber/cucumber_expressions/tree_regexp.rb
Instance Attribute Summary collapse
-
#group_builder ⇒ Object
readonly
Returns the value of attribute group_builder.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
-
#initialize(regexp) ⇒ TreeRegexp
constructor
A new instance of TreeRegexp.
- #match(s) ⇒ Object
Constructor Details
#initialize(regexp) ⇒ TreeRegexp
Returns a new instance of TreeRegexp.
11 12 13 14 |
# File 'lib/cucumber/cucumber_expressions/tree_regexp.rb', line 11 def initialize(regexp) @regexp = regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp) @group_builder = create_group_builder(@regexp) end |
Instance Attribute Details
#group_builder ⇒ Object (readonly)
Returns the value of attribute group_builder.
9 10 11 |
# File 'lib/cucumber/cucumber_expressions/tree_regexp.rb', line 9 def group_builder @group_builder end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
9 10 11 |
# File 'lib/cucumber/cucumber_expressions/tree_regexp.rb', line 9 def regexp @regexp end |
Instance Method Details
#match(s) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cucumber/cucumber_expressions/tree_regexp.rb', line 16 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 |