Class: TweetTail::TweetPoller
- Inherits:
-
Object
- Object
- TweetTail::TweetPoller
- Defined in:
- lib/tweet-tail/tweet_poller.rb
Instance Attribute Summary collapse
-
#latest_results ⇒ Object
Returns the value of attribute latest_results.
-
#query ⇒ Object
Returns the value of attribute query.
-
#refresh_url ⇒ Object
Returns the value of attribute refresh_url.
Instance Method Summary collapse
-
#initialize(query) ⇒ TweetPoller
constructor
A new instance of TweetPoller.
- #refresh ⇒ Object
- #render_latest_results ⇒ Object
Constructor Details
#initialize(query) ⇒ TweetPoller
Returns a new instance of TweetPoller.
6 7 8 |
# File 'lib/tweet-tail/tweet_poller.rb', line 6 def initialize(query) @query = query end |
Instance Attribute Details
#latest_results ⇒ Object
Returns the value of attribute latest_results.
4 5 6 |
# File 'lib/tweet-tail/tweet_poller.rb', line 4 def latest_results @latest_results end |
#query ⇒ Object
Returns the value of attribute query.
4 5 6 |
# File 'lib/tweet-tail/tweet_poller.rb', line 4 def query @query end |
#refresh_url ⇒ Object
Returns the value of attribute refresh_url.
4 5 6 |
# File 'lib/tweet-tail/tweet_poller.rb', line 4 def refresh_url @refresh_url end |
Instance Method Details
#refresh ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/tweet-tail/tweet_poller.rb', line 10 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 |
#render_latest_results ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/tweet-tail/tweet_poller.rb', line 20 def render_latest_results @latest_results.inject("") do |output, tweet| screen_name = tweet['from_user'] = tweet['text'] output += "#{screen_name}: #{}\n" end end |