Class: Zipmark::Pagination

Inherits:
Object
  • Object
show all
Defined in:
lib/zipmark/pagination.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Pagination

Returns a new instance of Pagination.

Raises:

  • (ArgumentError)


5
6
7
8
# File 'lib/zipmark/pagination.rb', line 5

def initialize(hash)
  raise ArgumentError, "expected hash" unless hash && hash.kind_of?(Hash)
  @pagination_hash = hash
end

Instance Attribute Details

#pagination_hashObject

Returns the value of attribute pagination_hash.



3
4
5
# File 'lib/zipmark/pagination.rb', line 3

def pagination_hash
  @pagination_hash
end

Instance Method Details

#current_pageObject



22
23
24
# File 'lib/zipmark/pagination.rb', line 22

def current_page
  pagination_hash["page"]
end

#first_page?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/zipmark/pagination.rb', line 26

def first_page?
  pagination_hash["first_page"]
end

#last_page?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/zipmark/pagination.rb', line 30

def last_page?
  pagination_hash["last_page"]
end

#pagesObject



10
11
12
# File 'lib/zipmark/pagination.rb', line 10

def pages
  pagination_hash["total_pages"]
end

#per_pageObject



18
19
20
# File 'lib/zipmark/pagination.rb', line 18

def per_page
  pagination_hash["per_page"]
end

#totalObject



14
15
16
# File 'lib/zipmark/pagination.rb', line 14

def total
  pagination_hash["total"]
end