jnunemaker / twitter

API wrapper for Twitter and Twitter Search API's

This URL has Read+Write access

jnunemaker (author)
Fri Jun 26 19:31:56 -0700 2009
commit  f9552f08068e913578910629c0d396b1a40ee992
tree    df5c914c79de750ec1dc5e200c30c78ce6d48c6b
parent  1a17828c2eaa32ef3a7b99ac0fef5caa50eedbec
twitter / lib / twitter / trends.rb
100644 29 lines (25 sloc) 0.772 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Twitter
  class Trends
    include HTTParty
    base_uri 'search.twitter.com/trends'
    format :json
    
    # :exclude => 'hashtags' to exclude hashtags
    def self.current(options={})
      mashup(get('/current.json', :query => options))
    end
    
    # :exclude => 'hashtags' to exclude hashtags
    # :date => yyyy-mm-dd for specific date
    def self.daily(options={})
      mashup(get('/daily.json', :query => options))
    end
    
    # :exclude => 'hashtags' to exclude hashtags
    # :date => yyyy-mm-dd for specific date
    def self.weekly(options={})
      mashup(get('/weekly.json', :query => options))
    end
    
    private
      def self.mashup(response)
        response['trends'].values.flatten.map { |t| Mash.new(t) }
      end
  end
end