Class: BudaApi::Models::PaginationMeta

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/buda_api/models.rb

Overview

Pagination metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#raw, #to_h, #to_json

Constructor Details

#initialize(data) ⇒ PaginationMeta

Returns a new instance of PaginationMeta.



303
304
305
306
307
308
# File 'lib/buda_api/models.rb', line 303

def initialize(data)
  super(data)
  @current_page = data["current_page"]&.to_i
  @total_count = data["total_count"]&.to_i
  @total_pages = data["total_pages"]&.to_i
end

Instance Attribute Details

#current_page ⇒ Object (readonly)

Returns the value of attribute current_page.



310
311
312
# File 'lib/buda_api/models.rb', line 310

def current_page
  @current_page
end

#total_count ⇒ Object (readonly)

Returns the value of attribute total_count.



310
311
312
# File 'lib/buda_api/models.rb', line 310

def total_count
  @total_count
end

#total_pages ⇒ Object (readonly)

Returns the value of attribute total_pages.



310
311
312
# File 'lib/buda_api/models.rb', line 310

def total_pages
  @total_pages
end

Instance Method Details

#has_next_page? ⇒ Boolean

Returns:

  • (Boolean)


312
313
314
# File 'lib/buda_api/models.rb', line 312

def has_next_page?
  @current_page && @total_pages && @current_page < @total_pages
end

#has_previous_page? ⇒ Boolean

Returns:

  • (Boolean)


316
317
318
# File 'lib/buda_api/models.rb', line 316

def has_previous_page?
  @current_page && @current_page > 1
end