Class: Algorithm::FollowEnumerator
- Inherits:
-
Enumerator
- Object
- Enumerator
- Algorithm::FollowEnumerator
- Defined in:
- lib/shellopts/ext/follow.rb
Instance Method Summary collapse
-
#initialize(object, method = nil, &block) ⇒ FollowEnumerator
constructor
A new instance of FollowEnumerator.
Constructor Details
#initialize(object, method = nil, &block) ⇒ FollowEnumerator
Returns a new instance of FollowEnumerator.
4 5 6 7 8 9 10 11 12 |
# File 'lib/shellopts/ext/follow.rb', line 4 def initialize(object, method = nil, &block) closure = method ? lambda { |object| object.__send__(method) } : block super() { |yielder| while object yielder << object object = closure.call(object) end } end |