Class: RegistersClient::RecordCollection
- Inherits:
-
Object
- Object
- RegistersClient::RecordCollection
- Includes:
- Enumerable
- Defined in:
- lib/record_collection.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(data, page_size = 100) ⇒ RecordCollection
constructor
A new instance of RecordCollection.
- #page(page = 1) ⇒ Object
Constructor Details
#initialize(data, page_size = 100) ⇒ RecordCollection
Returns a new instance of RecordCollection.
5 6 7 8 |
# File 'lib/record_collection.rb', line 5 def initialize(data, page_size = 100) @data = data @page_size = page_size end |
Instance Method Details
#each ⇒ Object
10 11 12 13 14 |
# File 'lib/record_collection.rb', line 10 def each @data.each do |record| yield record end end |
#page(page = 1) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/record_collection.rb', line 16 def page(page = 1) if @data.length <= @page_size @data else start_index = (page - 1) * @page_size @data.slice(start_index, @page_size) end end |