Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created February 9, 2011 03:43
Show Gist options
  • Save ashaw/817842 to your computer and use it in GitHub Desktop.
Save ashaw/817842 to your computer and use it in GitHub Desktop.
class Conversation
attr_reader :convo
def initialize(tweet)
tweet.to_s =~ /(\d+)$/
@tweet_id = $1 || raise("#{$1} is not a valid tweet")
@convo = []
end
def run
get_convo(@tweet_id.to_i)
end
def get_convo(tweet_id)
tweet = Twitter.status(tweet_id)
if tweet.in_reply_to_status_id_str
puts "adding #{tweet_id}"
@convo << {:status => tweet.text, :user => tweet.user.screen_name}
get_convo(tweet.in_reply_to_status_id_str.to_i)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment