Sha256: e0503a9703fb3cc5992486c064a047d55e2d7a82d88ca463d86b94fc4093a349

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

require 'twitter/base'

module Twitter
  class SearchResults < Twitter::Base

    # @return [Array<Twitter::Tweet>]
    def statuses
      @results ||= Array(@attrs[:statuses]).map do |tweet|
        Twitter::Tweet.fetch_or_new(tweet)
      end
    end
    alias collection statuses
    alias results statuses

    # @return [Float]
    def completed_in
      @attrs[:search_metadata][:completed_in] if search_metadata?
    end

    # @return [Integer]
    def max_id
      @attrs[:search_metadata][:max_id] if search_metadata?
    end

    # @return [Integer]
    def page
      @attrs[:search_metadata][:page] if search_metadata?
    end

    # @return [String]
    def query
      @attrs[:search_metadata][:query] if search_metadata?
    end

    # @return [Integer]
    def results_per_page
      @attrs[:search_metadata][:results_per_page] if search_metadata?
    end
    alias rpp results_per_page

    def search_metadata?
      !@attrs[:search_metadata].nil?
    end

    # @return [Integer]
    def since_id
      @attrs[:search_metadata][:since_id] if search_metadata?
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
twitter-4.6.1 lib/twitter/search_results.rb
twitter-4.6.0 lib/twitter/search_results.rb
twitter-4.5.0 lib/twitter/search_results.rb
twitter-4.4.4 lib/twitter/search_results.rb
twitter-4.4.3 lib/twitter/search_results.rb
twitter-4.4.2 lib/twitter/search_results.rb
twitter-4.4.1 lib/twitter/search_results.rb