Class: Twitter::TrendResults
- Inherits:
-
Object
- Object
- Twitter::TrendResults
- Includes:
- Memoizable, Creatable, Enumerable, Utils
- Defined in:
- lib/twitter/trend_results.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Hash
(also: #to_h)
readonly
Instance Method Summary collapse
-
#as_of ⇒ Time
Time when the object was created on Twitter.
-
#as_of? ⇒ Boolean
-
#initialize(attrs = {}) ⇒ Twitter::TrendResults
constructor
Initializes a new TrendResults object.
-
#location ⇒ Twitter::Place, NullObject
-
#location? ⇒ Boolean
Methods included from Utils
Methods included from Enumerable
Methods included from Creatable
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
#attrs ⇒ Hash (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_of ⇒ Time
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 |
#location ⇒ Twitter::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 |