Sha256: 3a0641c3cf55310ada987a91eaef482aba2103d5fd3580f5fdcb16443256115c

Contents?: true

Size: 498 Bytes

Versions: 10

Compression:

Stored size: 498 Bytes

Contents

module Skype
  @@filters = {}

  def self.response_filter(pattern, &block)
    raise ArgumentError, "pattern must be instance of Regexp" unless pattern.kind_of? Regexp
    raise ArgumentError, "block not given" unless block_given?
    @@filters[pattern] = block
  end

  def self.filter_response(response_string)
    @@filters.each do |filter, block|
      next unless response_string =~ filter
      response_string = block.call(response_string)
      break
    end
    response_string
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
skype-0.2.8 lib/skype/filter.rb
skype-0.2.7 lib/skype/filter.rb
skype-0.2.6 lib/skype/filter.rb
skype-0.2.5 lib/skype/filter.rb
skype-0.2.4 lib/skype/filter.rb
skype-0.2.3 lib/skype/filter.rb
skype-0.2.2 lib/skype/filter.rb
skype-0.2.1 lib/skype/filter.rb
skype-0.2.0 lib/skype/filter.rb
skype-0.1.5 lib/skype/filter.rb