class RestfulResource::PaginatedArray
Public Class Methods
Source
# File lib/restful_resource/paginated_array.rb, line 3 def initialize(original_array, previous_page_url:, next_page_url:, total_count:) super(original_array) @previous_page_url = previous_page_url @next_page_url = next_page_url @total_count = total_count end
Calls superclass method
Public Instance Methods
Source
# File lib/restful_resource/paginated_array.rb, line 15 def next_page get_page_from_url(@next_page_url) end
Source
# File lib/restful_resource/paginated_array.rb, line 11 def previous_page get_page_from_url(@previous_page_url) end
Source
# File lib/restful_resource/paginated_array.rb, line 19 def total_count @total_count.to_i end
Private Instance Methods
Source
# File lib/restful_resource/paginated_array.rb, line 25 def get_page_from_url(url) return nil unless url params = Rack::Utils.parse_query URI(url).query params['page'].to_i end