class AdwordsApi::ServiceQuery
Public Class Methods
new(query, start_index, page_size)
click to toggle source
# File lib/adwords_api/query_utils/service_query.rb, line 22 def initialize(query, start_index, page_size) @query = query @start_index = start_index @page_size = page_size end
Public Instance Methods
has_next(page)
click to toggle source
# File lib/adwords_api/query_utils/service_query.rb, line 28 def has_next(page) raise ArgumentError, 'Cannot page through query with no LIMIT clause.' if @start_index.nil? return @start_index + @page_size < page[:total_num_entries] end
has_next_landscape_page(page)
click to toggle source
Determining whether another page exists when dealing with bid landscapes is different from other types of queries. Use this method for those cases.
# File lib/adwords_api/query_utils/service_query.rb, line 36 def has_next_landscape_page(page) raise ArgumentError, 'Cannot page through query with no LIMIT clause.' if @start_index.nil? return false unless page[:entries] total_landscape_points_in_page = 0 page[:entries].each do |landscape| total_landscape_points_in_page += landscape[:landscape_points].size end return total_landscape_points_in_page >= @page_size end
next_page()
click to toggle source
# File lib/adwords_api/query_utils/service_query.rb, line 47 def next_page() raise ArgumentError, 'Cannot page through query with no LIMIT clause.' if @start_index.nil? @start_index += @page_size return self end
to_s()
click to toggle source
# File lib/adwords_api/query_utils/service_query.rb, line 54 def to_s() query = @query unless @start_index.nil? query += sprintf(' LIMIT %s,%s', @start_index, @page_size) end return query end