Class: Statement::Tweets
- Inherits:
-
Object
- Object
- Statement::Tweets
- Defined in:
- lib/statement/tweets.rb
Instance Attribute Summary collapse
-
#bulk_timeline(list_id, list_owner = nil) ⇒ Object
fetches latest 100 tweets from a list (derekwillis twitter acct has a public congress list).
-
#client ⇒ Object
Returns the value of attribute client.
-
#timeline(member_id) ⇒ Object
fetches single twitter user’s timeline.
Instance Method Summary collapse
-
#initialize ⇒ Tweets
constructor
A new instance of Tweets.
- #process_results(tweets) ⇒ Object
Constructor Details
#initialize ⇒ Tweets
Returns a new instance of Tweets.
9 10 11 12 13 14 15 16 17 |
# File 'lib/statement/tweets.rb', line 9 def initialize @@config = YAML.load_file("config.yml") rescue nil || {} @client = Twitter::Client.new( :consumer_key => ENV['CONSUMER_KEY'] || @@config['consumer_key'], :consumer_secret => ENV['CONSUMER_SECRET'] || @@config['consumer_secret'], :oauth_token => ENV['OAUTH_TOKEN'] || @@config['oauth_token'], :oauth_token_secret => ENV['OAUTH_TOKEN_SECRET'] || @@config['oauth_token_secret'] ) end |
Instance Attribute Details
#bulk_timeline(list_id, list_owner = nil) ⇒ Object
fetches latest 100 tweets from a list (derekwillis twitter acct has a public congress list)
25 26 27 |
# File 'lib/statement/tweets.rb', line 25 def bulk_timeline @bulk_timeline end |
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/statement/tweets.rb', line 7 def client @client end |
#timeline(member_id) ⇒ Object
fetches single twitter user’s timeline
20 21 22 |
# File 'lib/statement/tweets.rb', line 20 def timeline @timeline end |
Instance Method Details
#process_results(tweets) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/statement/tweets.rb', line 29 def process_results(tweets) results = [] tweets.each do |tweet| url = tweet[:urls].first ? tweet[:urls].first[:expanded_url] : nil results << { :id => tweet[:id], :body => tweet[:text], :link => url, :in_reply_to_screen_name => tweet[:in_reply_to_screen_name], :total_tweets => tweet[:user][:statuses_count], :created_time => tweet[:created_at], :retweets => tweet[:retweet_count], :favorites => tweet[:favorite_count], :screen_name => tweet[:user][:screen_name]} end results end |