Class: MR::FakePagedQuery
Instance Attribute Summary collapse
-
#page_num ⇒ Object
readonly
Returns the value of attribute page_num.
-
#page_offset ⇒ Object
readonly
Returns the value of attribute page_offset.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#total_count ⇒ Object
(also: #total_count!)
readonly
Returns the value of attribute total_count.
Attributes inherited from FakeQuery
Instance Method Summary collapse
- #has_next_page? ⇒ Boolean
-
#initialize(query, page_num, page_size) ⇒ FakePagedQuery
constructor
A new instance of FakePagedQuery.
- #is_last_page? ⇒ Boolean
Methods inherited from FakeQuery
Constructor Details
#initialize(query, page_num, page_size) ⇒ FakePagedQuery
Returns a new instance of FakePagedQuery.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mr/fake_query.rb', line 32 def initialize(query, page_num, page_size) @page_num = MR::PagedQuery::PageNumber.new(page_num) @page_size = MR::PagedQuery::PageSize.new(page_size) @page_offset = MR::PagedQuery::PageOffset.new(@page_num, @page_size) @unpaged_results = query.results.dup @total_count = @unpaged_results.size @has_next_page = (@page_offset + @page_size) < @total_count super(@unpaged_results.dup[@page_offset, @page_size]) end |
Instance Attribute Details
#page_num ⇒ Object (readonly)
Returns the value of attribute page_num.
29 30 31 |
# File 'lib/mr/fake_query.rb', line 29 def page_num @page_num end |
#page_offset ⇒ Object (readonly)
Returns the value of attribute page_offset.
29 30 31 |
# File 'lib/mr/fake_query.rb', line 29 def page_offset @page_offset end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
29 30 31 |
# File 'lib/mr/fake_query.rb', line 29 def page_size @page_size end |
#total_count ⇒ Object (readonly) Also known as: total_count!
Returns the value of attribute total_count.
29 30 31 |
# File 'lib/mr/fake_query.rb', line 29 def total_count @total_count end |
Instance Method Details
#has_next_page? ⇒ Boolean
43 44 45 |
# File 'lib/mr/fake_query.rb', line 43 def has_next_page? @has_next_page end |
#is_last_page? ⇒ Boolean
47 48 49 |
# File 'lib/mr/fake_query.rb', line 47 def is_last_page? !self.has_next_page? end |