class KOSapiClient::Entity::ResultPage
ResultPage
instance is returned from requests to all paginated resources. It wraps returned objects, stores additional feed metadata and it also helps to do things like auto pagination and next / previous page callbacks.
Attributes
auto_paginate[RW]
items[R]
Public Class Methods
new(items, links, auto_paginate = true)
click to toggle source
# File lib/kosapi_client/entity/result_page.rb, line 14 def initialize(items, links, auto_paginate = true) @items = items @links = links @auto_paginate = auto_paginate end
Public Instance Methods
count()
click to toggle source
# File lib/kosapi_client/entity/result_page.rb, line 20 def count @items.count end
each(&block)
click to toggle source
# File lib/kosapi_client/entity/result_page.rb, line 32 def each(&block) return to_enum(__method__) unless block_given? items.each(&block) return unless @auto_paginate next_link = self.next while next_link next_page = next_link.follow next_link = next_page.next next_page.items.each(&block) end end
next()
click to toggle source
# File lib/kosapi_client/entity/result_page.rb, line 24 def next @links.next end
prev()
click to toggle source
# File lib/kosapi_client/entity/result_page.rb, line 28 def prev @links.prev end