Class: Kommando::Matchers::Every

Inherits:
Base
  • Object
show all
Defined in:
lib/kommando/matchers/every.rb

Instance Attribute Summary

Attributes inherited from Base

#nested_matchers

Instance Method Summary collapse

Methods inherited from Base

#call, #every, #once

Constructor Details

#initialize(regexp, block) ⇒ Every

Returns a new instance of Every.



2
3
4
5
# File 'lib/kommando/matchers/every.rb', line 2

def initialize(regexp, block)
  super regexp, block
  @cursor = 0
end

Instance Method Details

#match(string) ⇒ Object



7
8
9
10
11
# File 'lib/kommando/matchers/every.rb', line 7

def match(string)
  match_data = string[@cursor..-1].match(@regexp)
  @cursor = string.length if match_data
  match_data
end

#skip_by(string) ⇒ Object



13
14
15
# File 'lib/kommando/matchers/every.rb', line 13

def skip_by(string)
  @cursor = string.length
end