Class: Endless
Instance Method Summary collapse
- #each ⇒ Object
- #get_promise ⇒ Object
-
#initialize ⇒ Endless
constructor
A new instance of Endless.
- #make_a_promise(p) ⇒ Object
- #map ⇒ Object
Constructor Details
#initialize ⇒ Endless
Returns a new instance of Endless.
9 10 11 |
# File 'lib/tarpaulin/endless.rb', line 9 def initialize make_a_promise Lazy.promise &Proc.new end |
Instance Method Details
#each ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tarpaulin/endless.rb', line 21 def each p = get_promise a = [] while p car, cdr = p head_by_tail = car[1] a << head_by_tail yield head_by_tail p = cdr.get_promise end a end |
#get_promise ⇒ Object
17 18 19 |
# File 'lib/tarpaulin/endless.rb', line 17 def get_promise @p end |
#make_a_promise(p) ⇒ Object
13 14 15 |
# File 'lib/tarpaulin/endless.rb', line 13 def make_a_promise(p) @p = p end |
#map ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tarpaulin/endless.rb', line 34 def map p = get_promise a = [] while p car, cdr = p head_by_tail = car[1] a << (yield head_by_tail) p = cdr.get_promise end a end |