Class: Inquisitio::Results

Inherits:
Array
  • Object
show all
Defined in:
lib/inquisitio/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items, current_page, results_per_page, total_count, time_ms) ⇒ Results

Returns a new instance of Results.



3
4
5
6
# File 'lib/inquisitio/results.rb', line 3

def initialize(items, current_page, results_per_page, total_count, time_ms)
  super(items)
  @current_page, @results_per_page, @total_count, @time_ms = current_page, results_per_page, total_count, time_ms
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



8
9
10
# File 'lib/inquisitio/results.rb', line 8

def current_page
  @current_page
end

#results_per_pageObject (readonly) Also known as: limit_value

Returns the value of attribute results_per_page.



8
9
10
# File 'lib/inquisitio/results.rb', line 8

def results_per_page
  @results_per_page
end

#time_msObject (readonly)

Returns the value of attribute time_ms.



8
9
10
# File 'lib/inquisitio/results.rb', line 8

def time_ms
  @time_ms
end

#total_countObject (readonly) Also known as: total_entries

Returns the value of attribute total_count.



8
9
10
# File 'lib/inquisitio/results.rb', line 8

def total_count
  @total_count
end

Instance Method Details

#last_page?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/inquisitio/results.rb', line 17

def last_page?
  current_page == total_pages
end

#to_aObject



21
22
23
# File 'lib/inquisitio/results.rb', line 21

def to_a
  self
end

#total_pagesObject Also known as: num_pages



12
13
14
# File 'lib/inquisitio/results.rb', line 12

def total_pages
  (total_count / results_per_page.to_f).ceil
end