module Elixir::Stream

Constants

INFINITY

Public Instance Methods

cycle(collection) click to toggle source
# File lib/elixir/stream.rb, line 7
def cycle collection
  collection.cycle
end
interval(milliseconds) click to toggle source
# File lib/elixir/stream.rb, line 11
def interval milliseconds
  Enumerator.new INFINITY do |yielder|
    0.upto INFINITY do |n|
      sleep milliseconds.fdiv 1000
      yielder << n
    end
  end
end
iterate(value) { |value| ... } click to toggle source
# File lib/elixir/stream.rb, line 20
def iterate value
  Enumerator.new INFINITY do |yielder|
    loop do
      yielder << value
      value = yield value
    end
  end
end
repeatedly() { || ... } click to toggle source
# File lib/elixir/stream.rb, line 29
def repeatedly
  Enumerator.new INFINITY do |yielder|
    loop do
      yielder << yield
    end
  end
end
timer(milliseconds) click to toggle source
# File lib/elixir/stream.rb, line 37
def timer milliseconds
  Enumerator.new 1 do |yielder|
    sleep milliseconds.fdiv 1000
    yielder << 0
  end
end
unfold(tuple) { |tuple| ... } click to toggle source
# File lib/elixir/stream.rb, line 44
def unfold tuple
  Enumerator.new INFINITY do |yielder|
    loop do
      value, tuple = yield tuple
      yielder << value
    end
  end
end