Class: Flox::ResourceEnumerator
- Inherits:
-
Object
- Object
- Flox::ResourceEnumerator
- Includes:
- Enumerable
- Defined in:
- lib/flox/resource_enumerator.rb
Overview
A helper class that stores the paths to a number of REST resources and supports iterating over those resources, downloading them lazily from the server.
Instance Attribute Summary collapse
-
#length ⇒ Fixnum
The total number of objects being enumerated.
Instance Method Summary collapse
-
#each ⇒ Object
Iterates over the resources provided on intialization, loading them from the server one by one.
-
#initialize(rest_service, paths) ⇒ ResourceEnumerator
constructor
A new instance of ResourceEnumerator.
Constructor Details
#initialize(rest_service, paths) ⇒ ResourceEnumerator
Returns a new instance of ResourceEnumerator.
19 20 21 22 |
# File 'lib/flox/resource_enumerator.rb', line 19 def initialize(rest_service, paths) @service = rest_service @paths = paths end |
Instance Attribute Details
#length ⇒ Fixnum
Returns the total number of objects being enumerated.
40 41 42 |
# File 'lib/flox/resource_enumerator.rb', line 40 def length @paths.length end |
Instance Method Details
#each ⇒ Object
Iterates over the resources provided on intialization, loading them from the server one by one.
26 27 28 29 30 |
# File 'lib/flox/resource_enumerator.rb', line 26 def each @paths.each do |path| yield @service.get(path) end end |