class Cucumber::CucumberExpressions::ParameterTypeMatcher

Attributes

parameter_type[R]

Public Class Methods

new(parameter_type, regexp, text, match_position=0) click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 6
def initialize(parameter_type, regexp, text, match_position=0)
  @parameter_type, @regexp, @text = parameter_type, regexp, text
  @match = @regexp.match(@text, match_position)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 38
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
advance_to(new_match_position) click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 11
def advance_to(new_match_position)
  (new_match_position...@text.length).each {|advancedPos|
    matcher = self.class.new(parameter_type, @regexp, @text, advancedPos)
    if matcher.find && matcher.full_word?
      return matcher
    end
  }

  self.class.new(parameter_type, @regexp, @text, @text.length)
end
find() click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 22
def find
  !@match.nil? && !group.empty?
end
full_word?() click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 26
def full_word?
  space_before_match_or_sentence_start? && space_after_match_or_sentence_end?
end
group() click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 34
def group
  @match.captures[0]
end
start() click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 30
def start
  @match.begin(0)
end

Private Instance Methods

space_after_match_or_sentence_end?() click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 53
def space_after_match_or_sentence_end?
  match_end = @match.end(0)
  match_end == @text.length || @text[match_end].match(/\p{Z}|\p{P}|\p{S}/)
end
space_before_match_or_sentence_start?() click to toggle source
# File lib/cucumber/cucumber_expressions/parameter_type_matcher.rb, line 48
def space_before_match_or_sentence_start?
  match_begin = @match.begin(0)
  match_begin == 0 || @text[match_begin - 1].match(/\p{Z}|\p{P}|\p{S}/)
end