Skip to content

Instantly share code, notes, and snippets.

@kaeff
Forked from unimatrixZxero/food.rb
Created September 7, 2011 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaeff/1200551 to your computer and use it in GitHub Desktop.
Save kaeff/1200551 to your computer and use it in GitHub Desktop.
Food script for campfire
require 'rubygems'
require 'tinder'
require 'uri'
class Food
def initialize(place=nil)
@place = place
end
def prefix
'FOOD: '
end
def out
prefix + "I've got my own here. I'm out."
end
def now(suggested_time='12:00')
prefix + "I'm very hungry. Let's go to #{place} at #{suggested_time}"
end
def later(suggested_time='12:55')
prefix + "I've just ate a late breakfast. Let's go to #{place} at #{suggested_time}"
end
def place
@place || random_place
end
def random_place
%w{Lumina Pasta-e-basta Pierhouse Stadtwerke Aaseemensa Kingdöner}.tap{|choices| return choices[rand(choices.size)]}
end
end
class FireChat
CONFIG = {
:room => '[zweitag.de] Lounge',
:sub_domain => 'zweitag',
:user => '',
:password => '',
:token => 'INSERT_YOUR_TOKEN_HERE_TO_MAKE_IT_WORK'
}
def room
@room ||= campfire.find_room_by_name CONFIG[:room]
end
def post(msg)
puts "Posting messsage \"#{msg}\" to #{room.name}"
room.speak msg
end
def campfire
@campfire ||= Tinder::Campfire.new(CONFIG[:sub_domain], :token => CONFIG[:token])
end
end
def food(place=nil)
Food.new(place)
end
def post(msg)
FireChat.new.post msg
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment