Class: Cucumber::CucumberExpressions::ParameterTypeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/cucumber_expressions/parameter_type_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameter_type, regexp, text, match_position = 0) ⇒ ParameterTypeMatcher

Returns a new instance of ParameterTypeMatcher.



6
7
8
9
# 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

Instance Attribute Details

#parameter_typeObject (readonly)

Returns the value of attribute parameter_type.



4
5
6
# File 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb', line 4

def parameter_type
  @parameter_type
end

Instance Method Details

#<=>(other) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb', line 27

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) ⇒ Object



11
12
13
# File 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb', line 11

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

#findObject



15
16
17
# File 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb', line 15

def find
  !@match.nil? && !group.empty?
end

#groupObject



23
24
25
# File 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb', line 23

def group
  @match.captures[0]
end

#startObject



19
20
21
# File 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb', line 19

def start
  @match.begin(0)
end