Skip to content

Instantly share code, notes, and snippets.

@bigthyme
Created November 24, 2012 23:36
Show Gist options
  • Save bigthyme/4141817 to your computer and use it in GitHub Desktop.
Save bigthyme/4141817 to your computer and use it in GitHub Desktop.
Easily Integrate with Twitter API (testing purposes only)
#require dependent libs
require "jumpstart_auth"
class JSTwitter
attr_reader :client
def initialize
puts "Initializing..."
@client = JumpstartAuth.twitter
end
def tweet(message)
if message.length >= 140
puts "People are yawning, please shorten your message"
else
puts "You've used " + message.length.to_s + " characters out of 140"
end
@client.update(message)
end
def run
puts "Welcome to the Command Line Twitter Client"
command = ""
while command != "q"
printf "enter command: "
input = gets.chomp
parts = input.split
command = parts[0]
case command
when 'q' then puts "Goodbye!"
when 't' then tweet(parts[1..-1].join(" "))
else
puts "I'm sorry, I don't know how to #{command}"
end
end
end
end
#execute scripts
jst = JSTwitter.new
#jst.tweet("Hello Testing 12345!")
jst.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment