Class: Cucumber::CucumberExpressions::ParameterType
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb
Constant Summary collapse
- ILLEGAL_PARAMETER_NAME_PATTERN =
/([\[\]()$.|?*+])/
- UNESCAPE_PATTERN =
/(\\([\[$.|?*+\]]))/
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#regexps ⇒ Object
readonly
Returns the value of attribute regexps.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name, regexp, type, transformer, use_for_snippets, prefer_for_regexp_match) ⇒ ParameterType
constructor
Create a new Parameter.
- #prefer_for_regexp_match? ⇒ Boolean
- #transform(self_obj, group_values) ⇒ Object
- #use_for_snippets? ⇒ Boolean
Constructor Details
#initialize(name, regexp, type, transformer, use_for_snippets, prefer_for_regexp_match) ⇒ ParameterType
Create a new Parameter
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 41 def initialize(name, regexp, type, transformer, use_for_snippets, prefer_for_regexp_match) raise "regexp can't be nil" if regexp.nil? raise "type can't be nil" if type.nil? raise "transformer can't be nil" if transformer.nil? raise "use_for_snippets can't be nil" if use_for_snippets.nil? raise "prefer_for_regexp_match can't be nil" if prefer_for_regexp_match.nil? self.class.check_parameter_type_name(name) unless name.nil? @name, @type, @transformer, @use_for_snippets, @prefer_for_regexp_match = name, type, transformer, use_for_snippets, prefer_for_regexp_match @regexps = string_array(regexp) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 9 def name @name end |
#regexps ⇒ Object (readonly)
Returns the value of attribute regexps.
9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 9 def regexps @regexps end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 9 def type @type end |
Class Method Details
.check_parameter_type_name(type_name) ⇒ Object
11 12 13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 11 def self.check_parameter_type_name(type_name) unless is_valid_parameter_type_name(type_name) raise CucumberExpressionError.new("Illegal character in parameter name {#{type_name}}. Parameter names may not contain '[]()$.|?*+'") end end |
.is_valid_parameter_type_name(type_name) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 17 def self.is_valid_parameter_type_name(type_name) unescaped_type_name = type_name.gsub(UNESCAPE_PATTERN) do $2 end !(ILLEGAL_PARAMETER_NAME_PATTERN =~ unescaped_type_name) end |
Instance Method Details
#<=>(other) ⇒ Object
57 58 59 60 61 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 57 def <=>(other) return -1 if prefer_for_regexp_match? && !other.prefer_for_regexp_match? return 1 if other.prefer_for_regexp_match? && !prefer_for_regexp_match? return name <=> other.name end |
#prefer_for_regexp_match? ⇒ Boolean
24 25 26 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 24 def prefer_for_regexp_match? @prefer_for_regexp_match end |
#transform(self_obj, group_values) ⇒ Object
53 54 55 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 53 def transform(self_obj, group_values) self_obj.instance_exec(*group_values, &@transformer) end |
#use_for_snippets? ⇒ Boolean
28 29 30 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/parameter_type.rb', line 28 def use_for_snippets? @use_for_snippets end |