Class: RestfulResource::PaginatedArray

Inherits:
Array
  • Object
show all
Defined in:
lib/restful_resource/paginated_array.rb

Instance Method Summary collapse

Constructor Details

#initialize(original_array, previous_page_url:, next_page_url:, total_count:) ⇒ PaginatedArray

Returns a new instance of PaginatedArray.



3
4
5
6
7
8
9
# 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

Instance Method Details

#next_pageObject



15
16
17
# File 'lib/restful_resource/paginated_array.rb', line 15

def next_page
  get_page_from_url(@next_page_url)
end

#previous_pageObject



11
12
13
# File 'lib/restful_resource/paginated_array.rb', line 11

def previous_page
  get_page_from_url(@previous_page_url)
end

#total_countObject



19
20
21
# File 'lib/restful_resource/paginated_array.rb', line 19

def total_count
  @total_count.to_i
end