class BikeReg::Collection

Attributes

data[R]
next_page[R]
prev_page[R]
total[R]

Public Class Methods

from_response(response, key:, type:, start_page:) click to toggle source
# File lib/bike_reg/collection.rb, line 7
def self.from_response(response, key:, type:, start_page:)
  body = response.body
  new(
    data: body[key].map { |attrs| type.new(attrs) },
    total: body['ResultCount'],
    start_page: start_page
  )
end
new(data:, total:, start_page:) click to toggle source
# File lib/bike_reg/collection.rb, line 16
def initialize(data:, total:, start_page:)
  @data = data
  @total = total
  @next_page = start_page.nil? ? 1 : start_page + 1
  @prev_page = start_page.nil? ? 0 : start_page - 1
end