Class: Evidence::ArrayStream

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/evidence/stream.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


40
41
42
# File 'lib/evidence/stream.rb', line 40

def eos?
  @array.empty?
end

#to_sObject



50
51
52
# File 'lib/evidence/stream.rb', line 50

def to_s
  "$[#{@array.inspect}]"
end