class Twitter::PremiumSearchResults

Attributes

attrs[R]

@return [Hash]

to_h[R]

@return [Hash]

to_hash[R]

@return [Hash]

Public Class Methods

new(request, request_config = {}) click to toggle source

Initializes a new SearchResults object

@param request [Twitter::REST::Request] @return [Twitter::PremiumSearchResults]

# File lib/twitter/premium_search_results.rb, line 20
def initialize(request, request_config = {})
  @client = request.client
  @request_method = request.verb
  @path = request.path
  @options = request.options
  @request_config = request_config
  @collection = []
  self.attrs = request.perform
end

Private Instance Methods

attrs=(attrs) click to toggle source

@param attrs [Hash] @return [Hash]

# File lib/twitter/premium_search_results.rb, line 59
def attrs=(attrs)
  @attrs = attrs
  @attrs.fetch(:results, []).collect do |tweet|
    @collection << Tweet.new(tweet)
  end
  @attrs
end
fetch_next_page() click to toggle source

@return [Hash]

# File lib/twitter/premium_search_results.rb, line 51
def fetch_next_page
  request = @client.premium_search(@options[:query], (@options.reject { |k| k == :query } || {}).merge(next_page), @request_config)

  self.attrs = request.attrs
end
last?() click to toggle source

@return [Boolean]

# File lib/twitter/premium_search_results.rb, line 33
def last?
  !next_page?
end
next_page() click to toggle source

Returns a Hash of query parameters for the next result in the search

@note Returned Hash can be merged into the previous search options list to easily access the next page. @return [Hash] The parameters needed to fetch the next page.

# File lib/twitter/premium_search_results.rb, line 46
def next_page
  {next: @attrs[:next]} if next_page?
end
next_page?() click to toggle source

@return [Boolean]

# File lib/twitter/premium_search_results.rb, line 38
def next_page?
  !!@attrs[:next]
end