Class: InfiniteStream
- Inherits:
-
Object
- Object
- InfiniteStream
- Defined in:
- lib/infinite_stream.rb
Overview
direct copy, with adaptations, of Generator class by Jim Weirich in Hal Fulton's book "The Ruby Way."
Direct Known Subclasses
Instance Method Summary (collapse)
- - (Object) generate(value)
-
- (InfiniteStream) initialize
constructor
A new instance of InfiniteStream.
- - (Object) next
Constructor Details
- (InfiniteStream) initialize
A new instance of InfiniteStream
5 6 7 8 9 10 11 |
# File 'lib/infinite_stream.rb', line 5 def initialize callcc do |context| @generator_context = context return end end |
Instance Method Details
- (Object) generate(value)
18 19 20 21 22 23 |
# File 'lib/infinite_stream.rb', line 18 def generate(value) callcc do |context| @generator_context = context @main_context[value] end end |
- (Object) next
12 13 14 15 16 17 |
# File 'lib/infinite_stream.rb', line 12 def next callcc do |here| @main_context = here @generator_context[] end end |