Class: Evidence::ArrayStream
- Inherits:
-
Object
- Object
- Evidence::ArrayStream
- Includes:
- Enumerable
- Defined in:
- lib/evidence/stream.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #eos? ⇒ Boolean
-
#initialize(array) ⇒ ArrayStream
constructor
A new instance of ArrayStream.
- #to_s ⇒ Object
Constructor Details
#initialize(array) ⇒ ArrayStream
Returns a new instance of ArrayStream.
36 37 38 |
# File 'lib/evidence/stream.rb', line 36 def initialize(array) @array = array end |
Instance Method Details
#each(&block) ⇒ Object
44 45 46 47 48 |
# File 'lib/evidence/stream.rb', line 44 def each(&block) while(item = @array.shift) do block.call(item) end end |
#eos? ⇒ Boolean
40 41 42 |
# File 'lib/evidence/stream.rb', line 40 def eos? @array.empty? end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/evidence/stream.rb', line 50 def to_s "$[#{@array.inspect}]" end |