Class: Cucumber::CucumberExpressions::RegularExpression
- Inherits:
-
Object
- Object
- Cucumber::CucumberExpressions::RegularExpression
- Defined in:
- lib/cucumber/cucumber_expressions/regular_expression.rb
Instance Method Summary collapse
-
#initialize(expression_regexp, parameter_type_registry) ⇒ RegularExpression
constructor
A new instance of RegularExpression.
- #match(text) ⇒ Object
- #regexp ⇒ Object
- #source ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(expression_regexp, parameter_type_registry) ⇒ RegularExpression
Returns a new instance of RegularExpression.
10 11 12 13 14 |
# File 'lib/cucumber/cucumber_expressions/regular_expression.rb', line 10 def initialize(expression_regexp, parameter_type_registry) @expression_regexp = expression_regexp @parameter_type_registry = parameter_type_registry @tree_regexp = TreeRegexp.new(@expression_regexp) end |
Instance Method Details
#match(text) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cucumber/cucumber_expressions/regular_expression.rb', line 16 def match(text) parameter_types = @tree_regexp.group_builder.children.map do |group_builder| parameter_type_regexp = group_builder.source @parameter_type_registry.lookup_by_regexp( parameter_type_regexp, @expression_regexp, text ) || ParameterType.new( nil, parameter_type_regexp, String, ->(*s) { s[0] }, false, false ) end Argument.build(@tree_regexp, text, parameter_types) end |
#regexp ⇒ Object
36 37 38 |
# File 'lib/cucumber/cucumber_expressions/regular_expression.rb', line 36 def regexp @expression_regexp end |
#source ⇒ Object
40 41 42 |
# File 'lib/cucumber/cucumber_expressions/regular_expression.rb', line 40 def source @expression_regexp.source end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/cucumber/cucumber_expressions/regular_expression.rb', line 44 def to_s regexp.inspect end |