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

Parameters:

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


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

#attrsHash (readonly) Also known as: to_h

Returns:

  • (Hash)


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

Returns:

  • (Time)


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

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

#as_of?Boolean

Returns:

  • (Boolean)


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

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

#locationTwitter::Place, NullObject



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

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

#location?Boolean

Returns:

  • (Boolean)


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

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