Class: Dhis2::Pager

Inherits:
Object
  • Object
show all
Defined in:
lib/dhis2/pager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Pager

Returns a new instance of Pager.



7
8
9
10
11
12
13
# File 'lib/dhis2/pager.rb', line 7

def initialize(hash)
  @page       = hash["page"]
  @page_count = hash["page_count"] || hash["pageCount"]
  @total      = hash["total"]
  @next_page  = hash["next_page"] || hash["nextPage"]
  @page_size  = hash["page_size"] || hash["pageSize"]
end

Instance Attribute Details

#next_pageObject (readonly)

Returns the value of attribute next_page.



5
6
7
# File 'lib/dhis2/pager.rb', line 5

def next_page
  @next_page
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'lib/dhis2/pager.rb', line 5

def page
  @page
end

#page_countObject (readonly)

Returns the value of attribute page_count.



5
6
7
# File 'lib/dhis2/pager.rb', line 5

def page_count
  @page_count
end

#page_sizeObject (readonly)

Returns the value of attribute page_size.



5
6
7
# File 'lib/dhis2/pager.rb', line 5

def page_size
  @page_size
end

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'lib/dhis2/pager.rb', line 5

def total
  @total
end

Instance Method Details

#last_page?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/dhis2/pager.rb', line 15

def last_page?
  page * page_size >= total
end