Class: Besepa::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/besepa/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, klass) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
11
# File 'lib/besepa/collection.rb', line 7

def initialize(response, klass)
  @pagination = false
  @items = []
  process_response(response, klass)
end

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



4
5
6
# File 'lib/besepa/collection.rb', line 4

def current_page
  @current_page
end

#itemsObject

Returns the value of attribute items.



4
5
6
# File 'lib/besepa/collection.rb', line 4

def items
  @items
end

#pagesObject

Returns the value of attribute pages.



4
5
6
# File 'lib/besepa/collection.rb', line 4

def pages
  @pages
end

#paginationObject (readonly)

Returns the value of attribute pagination.



5
6
7
# File 'lib/besepa/collection.rb', line 5

def pagination
  @pagination
end

#per_pageObject

Returns the value of attribute per_page.



4
5
6
# File 'lib/besepa/collection.rb', line 4

def per_page
  @per_page
end

#totalObject

Returns the value of attribute total.



4
5
6
# File 'lib/besepa/collection.rb', line 4

def total
  @total
end

Instance Method Details

#each(&block) ⇒ Object



13
14
15
# File 'lib/besepa/collection.rb', line 13

def each &block
  @items.each{|item| block.call(item)}
end