Skip to content

Instantly share code, notes, and snippets.

@jackieiscool
Created June 19, 2012 03:09
Show Gist options
  • Save jackieiscool/2952077 to your computer and use it in GitHub Desktop.
Save jackieiscool/2952077 to your computer and use it in GitHub Desktop.
Twitter Recursion
require 'jumpstart_auth'
class JSTwitter
attr_reader :client
def initialize
puts "Initializing"
@client = JumpstartAuth.twitter
end
def run
puts "I totally just figured out a way to make my twitter program use recursion and
tweet my messages in blocks of 140 characters at a time, not matter how long they are.
For all of my friends reading this who are not computer programmers, I'm sorry that
makes no since to you, but I'm super excited about it! If you are a very experienced
computer programmer, you also may be confused, if you do not remember what it was like
to be a beginner, and get excited about doing very simple things."
end
def tweet(message)
if message.length > 140
message[0..139] = message
@client.update(message)
message[140..-1].tweet
else
@client.update(message)
end
end
=begin def tweet(message)
if message.length > 140
puts "Don't you know how to use twitter....duh."
else
@client.update(message)
end
end
=end
end
jst = JSTwitter.new
jst.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment