Class: TwitterFriendly::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, Caching, CachingAndLogging
Includes:
REST::API, RateLimit, Utils
Defined in:
lib/twitter_friendly/client.rb

Constant Summary

Constants included from REST::Tweets

REST::Tweets::MAX_IDS_PER_REQUEST

Constants included from REST::Lists

REST::Lists::MAX_LISTS_PER_REQUEST, REST::Lists::MAX_MEMBERS_PER_REQUEST

Constants included from REST::Favorites

REST::Favorites::MAX_TWEETS_PER_REQUEST

Constants included from REST::Search

REST::Search::MAX_TWEETS_PER_REQUEST

Constants included from REST::Timelines

REST::Timelines::MAX_TWEETS_PER_REQUEST

Constants included from REST::Users

REST::Users::MAX_USERS_PER_REQUEST

Constants included from REST::FriendsAndFollowers

REST::FriendsAndFollowers::MAX_IDS_PER_REQUEST

Instance Method Summary collapse

Methods included from CachingAndLogging

caching, logging

Methods included from Caching

caching_resources_with_cursor, caching_tweets_with_max_id, caching_users

Methods included from RateLimit

#rate_limit

Methods included from REST::Tweets

#retweeters_ids

Methods included from REST::Lists

#list, #list_members, #memberships

Methods included from REST::Favorites

#favorites

Methods included from REST::Search

#search

Methods included from REST::Timelines

#home_timeline, #mentions_timeline, #user_timeline

Methods included from REST::Users

#blocked_ids, #user, #user?, #users, #verify_credentials

Methods included from REST::FriendsAndFollowers

#follower_ids, #followers, #friend_ids, #friend_ids_and_follower_ids, #friends, #friends_and_followers, #friendship?

Methods included from REST::Parallel

#parallel

Methods included from REST::Collector

#fetch_resources_with_cursor, #fetch_tweets_with_max_id

Methods included from REST::Utils

#credentials_hash

Methods included from Utils

#authenticating_user?, #authorized_user?, #uid_or_screen_name?

Constructor Details

#initialize(*args) ⇒ Client

Returns a new instance of Client.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/twitter_friendly/client.rb', line 27

def initialize(*args)
  options = args.extract_options!

  @twitter = Twitter::REST::Client.new(options.slice(:access_token, :access_token_secret, :consumer_key, :consumer_secret))
  options.except!(:access_token, :access_token_secret, :consumer_key, :consumer_secret)

  @cache = TwitterFriendly::Cache.new(options.slice(:cache_dir, :expires_in, :race_condition_ttl))
  options.except!(:cache_dir, :expires_in, :race_condition_ttl)

  @logger = TwitterFriendly::Logger.new(options.slice(:log_dir, :log_level))

  unless subscriber_attached?
    if @logger.level == ::Logger::DEBUG
      @@subscriber_attached = true
      TwitterFriendly::Logging.logger = @logger
      TwitterFriendly::TFLogSubscriber.attach_to :twitter_friendly
      TwitterFriendly::ASLogSubscriber.attach_to :active_support
    end
  end
end

Instance Method Details

#cacheObject



48
49
50
# File 'lib/twitter_friendly/client.rb', line 48

def cache
  @cache
end

#internal_clientObject



56
57
58
# File 'lib/twitter_friendly/client.rb', line 56

def internal_client
  @twitter
end

#loggerObject



52
53
54
# File 'lib/twitter_friendly/client.rb', line 52

def logger
  @logger
end

#subscriber_attached?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/twitter_friendly/client.rb', line 65

def subscriber_attached?
  @@subscriber_attached ||= false
end

#twitterObject



60
61
62
63
# File 'lib/twitter_friendly/client.rb', line 60

def twitter
  logger.warn "DEPRECATION WARNING: Use #internal_client instead of #twitter"
  internal_client
end