Class: Descartes::Quotone
- Inherits:
-
Object
- Object
- Descartes::Quotone
- Includes:
- Cinch::Plugin
- Defined in:
- lib/descartes/modules/quotone.rb
Instance Method Summary collapse
Instance Method Details
#execute(m, num = nil) ⇒ Object
30 31 32 |
# File 'lib/descartes/modules/quotone.rb', line 30 def execute(m, num = nil) m.reply get(num ? "http://quotone.giovannicapuano.net/api/get/#{num.to_i}.json" : 'http://quotone.giovannicapuano.net/api/random.json') end |
#get(url) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/descartes/modules/quotone.rb', line 23 def get(url) open(url) { |f| quote = JSON.parse f.read return "\##{quote['id']} - #{quote['source']} (#{quote['tags']})\n#{quote['quote'].nl2(' / ').decode}" } end |