Sha256: 53b842feb21a6548680c5e777a7709c28d3503190dddca55a851bc44ddcdaca3
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'twitter/creatable' require 'twitter/enumerable' require 'twitter/null_object' module Twitter class TrendResults include Twitter::Creatable include Twitter::Enumerable attr_reader :attrs alias to_h attrs alias to_hash attrs alias to_hsh attrs # Construct a new SearchResults object from a response hash # # @param response [Hash] # @return [Twitter::Base] def self.from_response(response={}) new(response[:body].first) end # Initializes a new SearchResults object # # @param attrs [Hash] # @return [Twitter::TrendResults] def initialize(attrs={}) @attrs = attrs @collection = Array(@attrs[:trends]).map do |trend| Twitter::Trend.new(trend) end end # Time when the object was created on Twitter # # @return [Time] def as_of @as_of ||= Time.parse(@attrs[:as_of]) if @attrs[:as_of] end def as_of? !!@attrs[:as_of] end # @return [Twitter::Place, NullObject] def location @location ||= if location? Twitter::Place.new(@attrs[:locations].first) else Twitter::NullObject.instance end end # @return [Boolean] def location? !@attrs[:locations].nil? && !@attrs[:locations].first.nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter-5.0.0.rc.1 | lib/twitter/trend_results.rb |