Sha256: 2484e5e99c7162a98c69496f3c227a5536b9d7dd8159005c0ef2c9fae2ef3538

Contents?: true

Size: 523 Bytes

Versions: 7

Compression:

Stored size: 523 Bytes

Contents

module Chatterbot

  #
  # class for holding onto a block/arguments we will use when calling
  # methods on the Twitter API
  #
  class Handler
    attr_reader :opts
    attr_reader :last_ran_at

    def initialize(opts, &block)
      if block_given?
        @opts = *opts
        @block = block
      else
        @opts = nil
        @block = opts
      end
    end

    #
    # call the block with the specified arguments
    #
    def call(*args)
      @last_ran_at = Time.now
      @block.call(*args)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chatterbot-2.2.0 lib/chatterbot/handler.rb
chatterbot-2.1.0 lib/chatterbot/handler.rb
chatterbot-2.0.5 lib/chatterbot/handler.rb
chatterbot-2.0.4 lib/chatterbot/handler.rb
chatterbot-2.0.3 lib/chatterbot/handler.rb
chatterbot-2.0.2 lib/chatterbot/handler.rb
chatterbot-2.0.0.pre lib/chatterbot/handler.rb