Class: Fortnox::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/fortnox/collection.rb

Overview

An iterable wrapper around a list of resource instances that also carries the pagination metadata Fortnox returns alongside collection responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items, total: nil, pages: nil, current_page: nil) ⇒ Collection

Returns a new instance of Collection.



16
17
18
19
20
21
# File 'lib/fortnox/collection.rb', line 16

def initialize(items, total: nil, pages: nil, current_page: nil)
  @items = items
  @total = total
  @pages = pages
  @current_page = current_page
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



14
15
16
# File 'lib/fortnox/collection.rb', line 14

def current_page
  @current_page
end

#pagesObject (readonly)

Returns the value of attribute pages.



14
15
16
# File 'lib/fortnox/collection.rb', line 14

def pages
  @pages
end

#totalObject (readonly)

Returns the value of attribute total.



14
15
16
# File 'lib/fortnox/collection.rb', line 14

def total
  @total
end