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

#initialize(attrs = {}) ⇒ Twitter::TrendResults

Initializes a new TrendResults object



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

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

Instance Attribute Details

#attrsHash (readonly) Also known as: to_h



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

def attrs
  @attrs
end

Instance Method Details

#as_ofTime

Time when the object was created on Twitter



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

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

#as_of?Boolean



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

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

#locationTwitter::Place, NullObject



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

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

#location?Boolean



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

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