Sha256: 08376731be6d51b96169480d1960ab0f46337d63a691c9d8a8f0681a5c739a10

Contents?: true

Size: 404 Bytes

Versions: 1

Compression:

Stored size: 404 Bytes

Contents

require 'stringio'

module RubyOnRuby
  class RubyStream
    attr_accessor :stream

    def initialize(stream = StringIO.new)
      @stream = stream
    end

    def input
      lambda do
        if stream.eof?
          nil
        else
          stream.read(1).ord
        end
      end
    end

    def output
      lambda do |this, char|
        stream.print char.to_i.chr
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_on_ruby-0.0.1 lib/ruby_on_ruby/ruby_stream.rb