Sha256: 0e38a91e12a17948d2df38cb0cf41ee9560848901fa53f8a2a3e047798261f88

Contents?: true

Size: 877 Bytes

Versions: 9

Compression:

Stored size: 877 Bytes

Contents

module Cucumber
  module CucumberExpressions
    class ParameterTypeMatcher
      attr_reader :parameter_type

      def initialize(parameter_type, regexp, text, match_position=0)
        @parameter_type, @regexp, @text = parameter_type, regexp, text
        @match = @regexp.match(@text, match_position)
      end

      def advance_to(new_match_position)
        self.class.new(parameter_type, @regexp, @text, new_match_position)
      end

      def find
        !@match.nil?
      end

      def start
        @match.begin(0)
      end

      def group
        @match.captures[0]
      end

      def <=>(other)
        pos_comparison = start <=> other.start
        return pos_comparison if pos_comparison != 0
        length_comparison = other.group.length <=> group.length
        return length_comparison if length_comparison != 0
        0
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cucumber-expressions-5.0.4 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.3 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.2 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.0 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-4.0.4 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-4.0.3 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-4.0.2 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-4.0.1 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-4.0.0 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb