Class: Cucumber::CucumberExpressions::CucumberExpression
- Inherits:
-
Object
- Object
- Cucumber::CucumberExpressions::CucumberExpression
- Defined in:
- lib/cucumber/cucumber_expressions/cucumber_expression.rb
Constant Summary collapse
- ESCAPE_REGEXP =
Does not include (){} characters because they have special meaning
/([\\^\[$.|?*+\]])/- PARAMETER_REGEXP =
/(\\\\)?{([^}]+)}/- OPTIONAL_REGEXP =
/(\\\\)?\(([^)]+)\)/- ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP =
/([^\s^\/]+)((\/[^\s^\/]+)+)/- DOUBLE_ESCAPE =
'\\\\'
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(expression, parameter_type_registry) ⇒ CucumberExpression
constructor
A new instance of CucumberExpression.
- #match(text) ⇒ Object
- #regexp ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(expression, parameter_type_registry) ⇒ CucumberExpression
Returns a new instance of CucumberExpression.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cucumber/cucumber_expressions/cucumber_expression.rb', line 17 def initialize(expression, parameter_type_registry) @source = expression @parameter_types = [] expression = process_escapes(expression) expression = process_optional(expression) expression = process_alternation(expression) expression = process_parameters(expression, parameter_type_registry) expression = "^#{expression}$" @tree_regexp = TreeRegexp.new(expression) end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
15 16 17 |
# File 'lib/cucumber/cucumber_expressions/cucumber_expression.rb', line 15 def source @source end |
Instance Method Details
#match(text) ⇒ Object
30 31 32 |
# File 'lib/cucumber/cucumber_expressions/cucumber_expression.rb', line 30 def match(text) Argument.build(@tree_regexp, text, @parameter_types) end |
#regexp ⇒ Object
34 35 36 |
# File 'lib/cucumber/cucumber_expressions/cucumber_expression.rb', line 34 def regexp @tree_regexp.regexp end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/cucumber/cucumber_expressions/cucumber_expression.rb', line 38 def to_s @source.inspect end |