steveklabnik / frappuccino

Functional Reactive Programming in Ruby.
https://github.com/steveklabnik/frappuccino
MIT License
354 stars 33 forks source link

Add #take and to_array #13

Closed seadowg closed 11 years ago

seadowg commented 11 years ago

This adds an implementation for Enumerable#take for Stream (takes a number n and returns a Stream that will stop occurring after n events). There might be some optimisations we could make to the implementation of this as callbacks and observers could all be cleaned up after the Stream 'finishes' but I've kept it simple for now.

I've also added a helper method to_array for testing that takes a Stream and returns a Ruby array representation of the contents (that stays up to date). All this really does is bind a callback to the stream that pushes occurrences into the returned array. This was how we were testing many of the operations for Stream and adding the helper seems to make the tests more concise.

coveralls commented 11 years ago

Coverage Status

Coverage remained the same when pulling 6db878630cf58468e2050ee7b7c6c8ac02edc9a2 on seadowg:master into deba8da66c8f59c9faa56b1745f6c4dca60cd391 on steveklabnik:master.

coveralls commented 11 years ago

Coverage Status

Coverage remained the same when pulling 6db878630cf58468e2050ee7b7c6c8ac02edc9a2 on seadowg:master into deba8da66c8f59c9faa56b1745f6c4dca60cd391 on steveklabnik:master.

coveralls commented 11 years ago

Coverage Status

Coverage remained the same when pulling f0747565e7c74d9791e03c79ef4acc37b5d9265a on seadowg:master into deba8da66c8f59c9faa56b1745f6c4dca60cd391 on steveklabnik:master.

coveralls commented 11 years ago

Coverage Status

Coverage remained the same when pulling f0747565e7c74d9791e03c79ef4acc37b5d9265a on seadowg:master into deba8da66c8f59c9faa56b1745f6c4dca60cd391 on steveklabnik:master.

steveklabnik commented 11 years ago

Great! Thanks so much!