Class: Cucumber::CucumberExpressions::Argument
- Inherits:
-
Object
- Object
- Cucumber::CucumberExpressions::Argument
- Defined in:
- lib/cucumber/cucumber_expressions/argument.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#parameter_type ⇒ Object
readonly
Returns the value of attribute parameter_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(group, parameter_type) ⇒ Argument
constructor
A new instance of Argument.
- #value(self_obj = :nil) ⇒ Object
Constructor Details
#initialize(group, parameter_type) ⇒ Argument
Returns a new instance of Argument.
29 30 31 |
# File 'lib/cucumber/cucumber_expressions/argument.rb', line 29 def initialize(group, parameter_type) @group, @parameter_type = group, parameter_type end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
9 10 11 |
# File 'lib/cucumber/cucumber_expressions/argument.rb', line 9 def group @group end |
#parameter_type ⇒ Object (readonly)
Returns the value of attribute parameter_type.
9 10 11 |
# File 'lib/cucumber/cucumber_expressions/argument.rb', line 9 def parameter_type @parameter_type end |
Class Method Details
.build(tree_regexp, text, parameter_types) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cucumber/cucumber_expressions/argument.rb', line 11 def self.build(tree_regexp, text, parameter_types) group = tree_regexp.match(text) return nil if group.nil? arg_groups = group.children if arg_groups.length != parameter_types.length raise CucumberExpressionError.new( "Expression #{tree_regexp.regexp.inspect} has #{arg_groups.length} capture groups (#{arg_groups.map(&:value)}), " \ "but there were #{parameter_types.length} parameter types (#{parameter_types.map(&:name)})" ) end parameter_types.zip(arg_groups).map do |parameter_type, arg_group| Argument.new(arg_group, parameter_type) end end |
Instance Method Details
#value(self_obj = :nil) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/cucumber/cucumber_expressions/argument.rb', line 33 def value(self_obj = :nil) raise 'No self_obj' if self_obj == :nil group_values = @group ? @group.values : nil @parameter_type.transform(self_obj, group_values) end |