Class: Zipmark::Collection
- Inherits:
-
Object
- Object
- Zipmark::Collection
- Includes:
- Enumerable
- Defined in:
- lib/zipmark/collection.rb
Instance Attribute Summary collapse
-
#iterator ⇒ Object
Returns the value of attribute iterator.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(resource, iterator_class) ⇒ Collection
constructor
A new instance of Collection.
- #items ⇒ Object
- #length ⇒ Object
Constructor Details
#initialize(resource, iterator_class) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 |
# File 'lib/zipmark/collection.rb', line 7 def initialize(resource, iterator_class) fetched_resource = resource.client.get(resource.href).body @iterator = iterator_class.new(fetched_resource, :resource_name => resource.rel, :client => resource.client) end |
Instance Attribute Details
#iterator ⇒ Object
Returns the value of attribute iterator.
5 6 7 |
# File 'lib/zipmark/collection.rb', line 5 def iterator @iterator end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 |
# File 'lib/zipmark/collection.rb', line 20 def each # Wrapping in the being block ensures that the current_item is yielded once before next_item is called begin yield iterator.current_item end while iterator.next_item end |
#items ⇒ Object
12 13 14 |
# File 'lib/zipmark/collection.rb', line 12 def items iterator.items end |
#length ⇒ Object
16 17 18 |
# File 'lib/zipmark/collection.rb', line 16 def length iterator.total_items end |