class RestfulResource::PaginatedArray

Public Class Methods

new(original_array, previous_page_url:, next_page_url:, total_count:) click to toggle source
Calls superclass method
# 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

Public Instance Methods

next_page() click to toggle source
# File lib/restful_resource/paginated_array.rb, line 15
def next_page
  get_page_from_url(@next_page_url)
end
previous_page() click to toggle source
# File lib/restful_resource/paginated_array.rb, line 11
def previous_page
  get_page_from_url(@previous_page_url)
end
total_count() click to toggle source
# File lib/restful_resource/paginated_array.rb, line 19
def total_count
  @total_count.to_i
end

Private Instance Methods

get_page_from_url(url) click to toggle 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