Module: Twitter::Client::Trends

Included in:
Twitter::Client
Defined in:
lib/twitter/client/trends.rb

Overview

Defines methods related to global trends

See Also:

Instance Method Summary collapse

Instance Method Details

Returns the top 20 trending topics for each hour in a given day

Examples:

Return the top 20 trending topics for each hour of October 24, 2010

Twitter.trends_daily(Date.parse("2010-10-24"))

Parameters:

  • date (Date) (defaults to: Date.today)

    The start date for the report. A 404 error will be thrown if the date is older than the available search index (7-10 days). Dates in the future will be forced to the current date.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :exclude (String)

    Setting this equal to 'hashtags' will remove all hashtags from the trends list.

Returns:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • No



20
21
22
23
24
25
26
27
28
29
# File 'lib/twitter/client/trends.rb', line 20

def trends_daily(date=Date.today, options={})
  trends = {}
  get("/1/trends/daily.json", options.merge(:date => date.strftime('%Y-%m-%d')))['trends'].each do |key, value|
    trends[key] = []
    value.each do |trend|
      trends[key] << Twitter::Trend.new(trend)
    end
  end
  trends
end

Returns the top 30 trending topics for each day in a given week

Examples:

Return the top ten topics that are currently trending on Twitter

Twitter.trends_weekly(Date.parse("2010-10-24"))

Parameters:

  • date (Date) (defaults to: Date.today)

    The start date for the report. A 404 error will be thrown if the date is older than the available search index (7-10 days). Dates in the future will be forced to the current date.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :exclude (String)

    Setting this equal to 'hashtags' will remove all hashtags from the trends list.

Returns:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • No



42
43
44
45
46
47
48
49
50
51
# File 'lib/twitter/client/trends.rb', line 42

def trends_weekly(date=Date.today, options={})
  trends = {}
  get("/1/trends/weekly.json", options.merge(:date => date.strftime('%Y-%m-%d')))['trends'].each do |key, value|
    trends[key] = []
    value.each do |trend|
      trends[key] << Twitter::Trend.new(trend)
    end
  end
  trends
end