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
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
#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
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
37 38 39 |
# File 'lib/twitter/trend_results.rb', line 37 def as_of? !!@attrs[:as_of] end |
#location ⇒ Twitter::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
49 50 51 |
# File 'lib/twitter/trend_results.rb', line 49 def location? !@attrs[:locations].nil? && !@attrs[:locations].first.nil? end |