Class: Videojuicer::Resource::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/videojuicer/resource/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects, total, offset, limit) ⇒ Collection

Returns a new instance of Collection.



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

def initialize(objects, total, offset, limit)
  clear
  objects.each {|o| self << o }
  self.total = total
  self.offset = offset
  self.limit = limit
end

Instance Attribute Details

#limitObject

Returns the value of attribute limit.



12
13
14
# File 'lib/videojuicer/resource/collection.rb', line 12

def limit
  @limit
end

#offsetObject

Returns the value of attribute offset.



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

def offset
  @offset
end

#totalObject

Returns the value of attribute total.



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

def total
  @total
end

Instance Method Details

#page_countObject



24
25
26
# File 'lib/videojuicer/resource/collection.rb', line 24

def page_count
  (total.to_f/limit.to_f).ceil
end

#page_numberObject



28
29
30
# File 'lib/videojuicer/resource/collection.rb', line 28

def page_number
  (offset.to_f/limit.to_f).ceil
end