Class: Lita::Handlers::Revolution

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/revolution.rb

Constant Summary collapse

REDIS_KEY =
"quote"

Instance Method Summary collapse

Instance Method Details

#collect_with_max_id(collection = [], max_id = nil, &block) ⇒ Object



16
17
18
19
20
# File 'lib/lita/handlers/revolution.rb', line 16

def collect_with_max_id(collection=[], max_id=nil, &block)
  response = yield(max_id)
  collection += response
  response.empty? ? collection.flatten : collect_with_max_id(collection, response.last.id - 1, &block)
end

#show_quote(response) ⇒ Object



42
43
44
# File 'lib/lita/handlers/revolution.rb', line 42

def show_quote(response)
  response.reply redis.lrange(quote, 0, -1).values.sample
end