Class: Twitter::TrendResults

Inherits:
Object
  • Object
show all
Includes:
Memoizable, Creatable, Enumerable, Utils
Defined in:
lib/twitter/trend_results.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Utils

flat_pmap, pmap

Methods included from Enumerable

#each

Methods included from Creatable

#created?, #created_at

Constructor Details

- (Twitter::TrendResults) initialize(attrs = {})

Initializes a new TrendResults object



22
23
24
25
26
27
# File 'lib/twitter/trend_results.rb', line 22

def initialize(attrs = {})
  @attrs = attrs
  @collection = @attrs.fetch(:trends, []).collect do |trend|
    Trend.new(trend)
  end
end

Instance Attribute Details

- (Object) attrs (readonly) Also known as: to_h

Returns the value of attribute attrs



13
14
15
# File 'lib/twitter/trend_results.rb', line 13

def attrs
  @attrs
end

Instance Method Details

- (Time) as_of

Time when the object was created on Twitter



32
33
34
# File 'lib/twitter/trend_results.rb', line 32

def as_of
  Time.parse(@attrs[:as_of]) unless @attrs[:as_of].nil?
end

- (Boolean) as_of?



37
38
39
# File 'lib/twitter/trend_results.rb', line 37

def as_of?
  !!@attrs[:as_of]
end

- (Twitter::Place, NullObject) location



43
44
45
# File 'lib/twitter/trend_results.rb', line 43

def location
  location? ? Place.new(@attrs[:locations].first) : NullObject.new
end

- (Boolean) location?



49
50
51
# File 'lib/twitter/trend_results.rb', line 49

def location?
  !@attrs[:locations].nil? && !@attrs[:locations].first.nil?
end