Class: Trendy::Trends

Inherits:
Array
  • Object
show all
Defined in:
lib/trendy.rb

Overview

Trends is an array which contains Trend objects use these Trend objects to access information about a particular trend

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTrends

Returns a new instance of Trends.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/trendy.rb', line 13

def initialize
  @url = 'http://search.twitter.com/trends.json'
  result = read_twitter

  trends = result['trends']
  
  @datetime = result['as_of']
  
  trends.each do |subject|
    trend = Trend.new
    trend.name = subject['name']
    trend.url = subject['url']
    self.push(trend)
  end
end

Instance Attribute Details

#datetimeObject (readonly)

Returns the value of attribute datetime.



11
12
13
# File 'lib/trendy.rb', line 11

def datetime
  @datetime
end

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/trendy.rb', line 11

def url
  @url
end