Module: Lab42::StateMachine::Controller::StreamApi
- Extended by:
- Forwarder
- Included in:
- Lab42::StateMachine::Controller
- Defined in:
- lib/lab42/state_machine/controller/stream_api.rb
Instance Method Summary collapse
- #drop_until(&condition) ⇒ Object
- #drop_until!(&condition) ⇒ Object
- #drop_while(&condition) ⇒ Object
- #drop_while!(&condition) ⇒ Object
- #has_next? ⇒ Boolean
- #last? ⇒ Boolean
- #peek(*args) ⇒ Object
- #reject(&filter) ⇒ Object
- #rewind ⇒ Object
- #rewind! ⇒ Object
- #select(&filter) ⇒ Object
- #take_until(&condition) ⇒ Object
Instance Method Details
#drop_until(&condition) ⇒ Object
16 17 18 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 16 def drop_until &condition @stream = stream.drop_while( &condition.negated ) end |
#drop_until!(&condition) ⇒ Object
19 20 21 22 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 19 def drop_until! &condition drop_until( &condition ) @sm.skip end |
#drop_while(&condition) ⇒ Object
24 25 26 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 24 def drop_while &condition @stream = stream.drop_while( &condition ) end |
#drop_while!(&condition) ⇒ Object
27 28 29 30 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 27 def drop_while! &condition drop_while( &condition ) @sm.skip end |
#has_next? ⇒ Boolean
32 33 34 35 36 37 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 32 def has_next? stream.peek true rescue StopIteration false end |
#last? ⇒ Boolean
38 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 38 def last?; !has_next? end |
#peek(*args) ⇒ Object
40 41 42 43 44 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 40 def peek *args stream.peek rescue StopIteration args.first end |
#reject(&filter) ⇒ Object
46 47 48 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 46 def reject &filter @stream = @stream.reject( &filter ) end |
#rewind ⇒ Object
50 51 52 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 50 def rewind @stream = @original_stream end |
#rewind! ⇒ Object
54 55 56 57 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 54 def rewind! rewind @sm.skip end |
#select(&filter) ⇒ Object
59 60 61 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 59 def select &filter @stream = @stream.select( &filter ) end |
#take_until(&condition) ⇒ Object
63 64 65 |
# File 'lib/lab42/state_machine/controller/stream_api.rb', line 63 def take_until &condition take_while( &condition.negated ) end |