Sha256: 8cae466e2685a39fe23a3f8d8e31ef21576c3a226f98c9c4919368bced0e72fd
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'cucumber/cucumber_expressions/group' require 'cucumber/cucumber_expressions/errors' module Cucumber module CucumberExpressions class Argument attr_reader :group, :parameter_type 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 def initialize(group, parameter_type) @group, @parameter_type = group, parameter_type end 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 end end end
Version data entries
6 entries across 6 versions & 2 rubygems