class Pipelines::Pipeline

Public Class Methods

new() click to toggle source
# File lib/readingme/pipelines.rb, line 14
def initialize
  @output, @input = IO.pipe
end

Public Instance Methods

<<(data) click to toggle source
# File lib/readingme/pipelines.rb, line 30
def << data
  data = Array(data) unless data.is_a? IO
  data.each do |line|
    @input.puts line
  end
end
add(callable) click to toggle source
# File lib/readingme/pipelines.rb, line 18
def add callable
  l_out = @output
  n_out, n_in = IO.pipe
  @output = n_out
  Thread.new do
    callable.call(l_out, n_in)
    n_in.close
  end
  self
end
Also aliased as: |
close() click to toggle source
# File lib/readingme/pipelines.rb, line 37
def close; @input.close; end
Also aliased as: stop
each(&block) click to toggle source
# File lib/readingme/pipelines.rb, line 41
def each(&block); @output.each(&block); end
read() click to toggle source
# File lib/readingme/pipelines.rb, line 40
def read; @output.read; end
stop()
Alias for: close
|(callable)
Alias for: add