Method: T::Search#favorites

Defined in:
lib/t/search.rb

#favorites(*args) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/t/search.rb', line 65

def favorites(*args)
  query = args.pop
  user = args.pop
  opts = {count: MAX_NUM_RESULTS}
  opts[:include_entities] = !!options["decode_uris"]
  if user
    require "t/core_ext/string"
    user = options["id"] ? user.to_i : user.strip_ats
    tweets = collect_with_max_id do |max_id|
      opts[:max_id] = max_id unless max_id.nil?
      client.favorites(user, opts)
    end
  else
    tweets = collect_with_max_id do |max_id|
      opts[:max_id] = max_id unless max_id.nil?
      client.favorites(opts)
    end
  end
  tweets = tweets.select do |tweet|
    /#{query}/i.match(tweet.full_text)
  end
  print_tweets(tweets)
end