Sha256: 5690800e325ec8ff46284d74eaa3806d74136f8b7ff97d09861ce932b0279a15

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

class Kommando::Matchers::Base
  attr_reader :nested_matchers
  
  def initialize(regexp, block)
    @regexp = regexp
    @block = block

    @nested_matchers = []
  end

  def match(string)
    raise "#match not implemented"
  end

  def call(match_data=nil)
    return unless @block
    @block.call match_data
  end

  def once(regexp, &block)
    m = Kommando::Matchers::Once.new regexp, block
    @nested_matchers << m
    m
  end

  def every(regexp, &block)
    m = Kommando::Matchers::Every.new regexp, block
    @nested_matchers << m
    m
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kommando-0.1.2 lib/kommando/matchers/base.rb
kommando-0.1.1 lib/kommando/matchers/base.rb
kommando-0.1.0 lib/kommando/matchers/base.rb