Sha256: 0961b3d75f2d47b509beba5c5a74da68818711cc720ab859c5288ea930d7533d

Contents?: true

Size: 894 Bytes

Versions: 15

Compression:

Stored size: 894 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? && !group.empty?
      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

15 entries across 15 versions & 2 rubygems

Version Path
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/cucumber-expressions-6.0.1/lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-6.0.1 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-6.0.0 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.18 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.17 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.16 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.15 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.14 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.13 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.12 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.11 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.10 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.7 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.6 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
cucumber-expressions-5.0.5 lib/cucumber/cucumber_expressions/parameter_type_matcher.rb