Class: Twords::TwitterClient
- Inherits:
-
Object
- Object
- Twords::TwitterClient
- Includes:
- ConfigAccessible
- Defined in:
- lib/twords/twitter_client.rb
Overview
Twitter REST API client
Instance Attribute Summary collapse
-
#client ⇒ Twitter::REST::Client
readonly
A Twitter::REST::Client that provides a direct interface to the Twitter API.
Instance Method Summary collapse
-
#filter_tweets(screen_names) ⇒ Array<Twitter::Tweet>
Fetches the timelines for an array of screen names and filters them by the configured time range.
-
#initialize {|Twitter::REST::Client| ... } ⇒ TwitterClient
constructor
Initializes a new Twords::TwitterClient object and assigns to the @client instance variable.
Methods included from ConfigAccessible
Constructor Details
#initialize {|Twitter::REST::Client| ... } ⇒ TwitterClient
Initializes a new Twords::TwitterClient object and assigns to the @client instance variable
Twords::TwitterClient.new do |twitter|
twitter.consumer_key = "YOUR_CONSUMER_KEY"
twitter.consumer_secret = "YOUR_CONSUMER_SECRET"
twitter.access_token = "YOUR_ACCESS_TOKEN"
twitter.access_token_secret = "YOUR_ACCESS_SECRET"
end
for block { |twitter| … }
30 31 32 |
# File 'lib/twords/twitter_client.rb', line 30 def initialize(&block) @client = Twitter::REST::Client.new(&block) end |
Instance Attribute Details
#client ⇒ Twitter::REST::Client (readonly)
A Twitter::REST::Client that provides a direct interface to the Twitter API
14 15 16 |
# File 'lib/twords/twitter_client.rb', line 14 def client @client end |
Instance Method Details
#filter_tweets(screen_names) ⇒ Array<Twitter::Tweet>
Fetches the timelines for an array of screen names and filters them by the configured time range.
40 41 42 43 44 45 |
# File 'lib/twords/twitter_client.rb', line 40 def filter_tweets(screen_names) full_timeline(screen_names).each_with_object([]) do |tweet, memo| next if tweet.created_at > up_to_time memo << tweet if age_of_tweet_in_days(tweet) <= range end end |