Andreas Nedbal
2014-11-15T23:44:24Z

bottles_of_beer.rb

| #!/usr/bin/env ruby
| require "twitter"
|
| # Twitter client configuration
| client = Twitter::REST::Client.new do |config|
| config.consumer_key = YOUR_KEYS_HERE
| config.consumer_secret = YOUR_KEYS_HERE
| config.access_token = YOUR_KEYS_HERE
| config.access_token_secret = YOUR_KEYS_HERE
| end
|
| bottles = 99
|
| loop do
| if bottles > 2
| text = "#{bottles} bottles of beer on the wall, #{bottles} bottles of beer.\nTake one down and pass it around, #{bottles - 1} bottles of beer on the wall."
| bottles -= 1
| elsif bottles > 1
| text = "#{bottles} bottles of beer on the wall, #{bottles} bottles of beer.\nTake one down and pass it around, #{bottles - 1} bottle of beer on the wall."
| bottles -= 1
| elsif bottles > 0
| text = "#{bottles} bottle of beer on the wall, #{bottles} bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall."
| bottles -= 1
| elsif bottles == 0
| bottles = 99
| text = "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, #{bottles} bottles of beer on the wall."
| end
|
| client.update text
| sleep 15
| end