Class: Cucumber::CucumberExpressions::TransformMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transform, regexp, text, match_position = 0) ⇒ TransformMatcher

Returns a new instance of TransformMatcher.



6
7
8
9
# File 'lib/cucumber/cucumber_expressions/transform_matcher.rb', line 6

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

Instance Attribute Details

#transformObject (readonly)

Returns the value of attribute transform.



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

def transform
  @transform
end

Instance Method Details

#<=>(other) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/cucumber/cucumber_expressions/transform_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/transform_matcher.rb', line 11

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

#findObject



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

def find
  !@match.nil?
end

#groupObject



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

def group
  @match.captures[0]
end

#startObject



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

def start
  @match.begin(0)
end