Sha256: bcc198f9c040f64a418df3ae8d0d100d956c09228642193a5cba1dfcec3e52c0
Contents?: true
Size: 886 Bytes
Versions: 1
Compression:
Stored size: 886 Bytes
Contents
require 'net/http' class TweetTail::TweetPoller attr_accessor :query, :latest_results, :refresh_url def initialize(query) @query = query end def refresh unless @refresh_url @latest_feed = JSON.parse(initial_json_data) else @latest_feed = JSON.parse(refresh_json_data) end @latest_results = @latest_feed["results"].reverse @refresh_url = @latest_feed["refresh_url"] end def render_latest_results @latest_results.inject("") do |output, tweet| screen_name = tweet['from_user'] message = tweet['text'] output += "#{screen_name}: #{message}\n" end end protected def initial_json_data Net::HTTP.get(URI.parse("http://search.twitter.com/search.json?q=#{query}")) end def refresh_json_data Net::HTTP.get(URI.parse("http://search.twitter.com/search.json#{refresh_url}")) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tweettail-1.1.0 | lib/tweet-tail/tweet_poller.rb |