Class: Vpim::Enumerator
- Inherits:
-
Object
- Object
- Vpim::Enumerator
- Includes:
- Enumerable
- Defined in:
- lib/vpim/enumerator.rb
Overview
This is a way for an object to have multiple ways of being enumerated via argument to it’s #each() method. An Enumerator mixes in Enumerable, so the standard APIs such as Enumerable#map(), Enumerable#to_a(), and Enumerable#find_all() can be used on it.
TODO since 1.8, this is part of the standard library, I should rewrite vPim so this can be removed.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(obj, *args) ⇒ Enumerator
constructor
A new instance of Enumerator.
Constructor Details
#initialize(obj, *args) ⇒ Enumerator
Returns a new instance of Enumerator.
22 23 24 25 |
# File 'lib/vpim/enumerator.rb', line 22 def initialize(obj, *args) @obj = obj @args = args end |
Instance Method Details
#each(&block) ⇒ Object
27 28 29 |
# File 'lib/vpim/enumerator.rb', line 27 def each(&block) @obj.each(*@args, &block) end |