Sha256: 9518b86f0c0099ac06f8d16157cd4b1772ea1aa69f4f97ae464ba40091d6ce62
Contents?: true
Size: 1.19 KB
Versions: 12
Compression:
Stored size: 1.19 KB
Contents
module TheCity # This class is the base class for all TheCity objects and is meant to be inherited. # class ApiList attr_reader :total_entries, :total_pages, :per_page, :current_page def self.load(options = {}) self.new(options) end # Checks if there is a next page. # # @return true for yes, false for no. def next_page? @current_page < @total_pages end # Gets the next page of results. # # @return [UserList] or nil if there are no more pages. def next_page return nil unless next_page? self.class.new( @options.merge({:page => @options[:page]+1}) ) end # Loads the next page of results and replaces self with the results. # # @return true on success or otherwise false. def next_page! return false unless next_page? @options[:page] += 1 @options[:reader] = @options[:reader].class.new(@options) @json_data = @options[:reader].load_feed @total_entries = @json_data['total_entries'] @total_pages = @json_data['total_pages'] @per_page = @json_data['per_page'] @current_page = @json_data['current_page'] return true end end end
Version data entries
12 entries across 12 versions & 1 rubygems