Class: EnumUtils::ExhaustibleIter
- Inherits:
-
Object
- Object
- EnumUtils::ExhaustibleIter
- Defined in:
- lib/enum_utils/exhaustible_iter.rb
Overview
This is an enumerator wrapper that always caches 1 item in its buffer, and provides the ability to check if underlying enumerator is exhausted.
Constant Summary collapse
- EXHAUSTED =
Object.new
Instance Attribute Summary collapse
-
#buff_value ⇒ Object
readonly
Returns the value of attribute buff_value.
Instance Method Summary collapse
- #exhausted? ⇒ Boolean
-
#initialize(source) ⇒ ExhaustibleIter
constructor
A new instance of ExhaustibleIter.
- #next ⇒ Object
Constructor Details
#initialize(source) ⇒ ExhaustibleIter
Returns a new instance of ExhaustibleIter.
9 |
# File 'lib/enum_utils/exhaustible_iter.rb', line 9 def initialize(source); @source = source; pull end |
Instance Attribute Details
#buff_value ⇒ Object (readonly)
Returns the value of attribute buff_value.
7 8 9 |
# File 'lib/enum_utils/exhaustible_iter.rb', line 7 def buff_value @buff_value end |
Instance Method Details
#exhausted? ⇒ Boolean
10 |
# File 'lib/enum_utils/exhaustible_iter.rb', line 10 def exhausted?; @buff_value.equal?(EXHAUSTED) end |
#next ⇒ Object
11 |
# File 'lib/enum_utils/exhaustible_iter.rb', line 11 def next; @buff_value.tap { pull } end |