Class: Enumerator
- Inherits:
-
Object
- Object
- Enumerator
- Defined in:
- lib/time_calc/value.rb
Overview
TODO: Replace with backports after 2.7 release
Constant Summary collapse
- NOVALUE =
Object.new.freeze
Class Method Summary collapse
Class Method Details
.produce(initial = NOVALUE) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/time_calc/value.rb', line 16 def self.produce(initial = NOVALUE) fail ArgumentError, 'No block given' unless block_given? Enumerator.new do |y| val = initial == NOVALUE ? yield() : initial loop do y << val val = yield(val) end end end |