Sha256: e06a07a2651dfb947a0f7e42f08eeea7c44e2c06c2c1a27d13d32cfd3cbc184b
Contents?: true
Size: 606 Bytes
Versions: 3
Compression:
Stored size: 606 Bytes
Contents
module Contactually class Collection extend Forwardable include Enumerable attr_reader :items, :next_page, :previous_page, :total def initialize(items, meta: {}) @items = items @next_page = meta['next_page'] @previous_page = meta['previous_page'] @total = meta['total'] end def each(&block) items.each do |item| block.call(item) end end def has_next_page? !next_page.nil? end def has_previous_page? !previous_page.nil? end def_delegator :items, :last def_delegator :items, :size end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
contactually-rb-0.1.3 | lib/contactually/collection.rb |
contactually-rb-0.1.2 | lib/contactually/collection.rb |
contactually-rb-0.1.1 | lib/contactually/collection.rb |