Sha256: f7013776d2f24aac2090d01997d8390cdb0d29da9c90d167111d0c046c6266ae

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

class IO
  SEEK_SET = 0
  SEEK_CUR = 1
  SEEK_END = 2

  def tty?
    @tty
  end

  def closed?
    @closed
  end

  attr_accessor :write_proc

  def write(string)
    `self.write_proc(string)`
    string.size
  end

  attr_accessor :sync

  module Writable
    def <<(string)
      write(string)
      self
    end

    def print(*args)
      write args.map { |arg| String(arg) }.join($,)
      nil
    end

    def puts(*args)
      newline = $/
      if args.empty?
        write $/
      else
        write args.map { |arg| String(arg).chomp }.concat([nil]).join(newline)
      end
      nil
    end
  end

  module Readable
    def readbyte
      getbyte
    end

    def readchar
      getc
    end

    def readline(sep = $/)
      raise NotImplementedError
    end

    def readpartial(integer, outbuf = nil)
      raise NotImplementedError
    end
  end
end

STDERR = $stderr = IO.new
STDIN  = $stdin  = IO.new
STDOUT = $stdout = IO.new


$stdout.write_proc = `typeof(process) === 'object' ? function(s){process.stdout.write(s)} : function(s){console.log(s)}`
$stderr.write_proc = `typeof(process) === 'object' ? function(s){process.stderr.write(s)} : function(s){console.warn(s)}`

$stdout.extend(IO::Writable)
$stderr.extend(IO::Writable)

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
opal-0.9.0.beta2 opal/corelib/io.rb
opal-0.9.0.beta1 opal/corelib/io.rb
opal-0.8.1 opal/corelib/io.rb
opal-0.8.1.rc1 opal/corelib/io.rb
opal-wedge-0.9.0.dev opal/corelib/io.rb
opal-0.8.0 opal/corelib/io.rb
opal-0.8.0.rc3 opal/corelib/io.rb
opal-0.8.0.rc2 opal/corelib/io.rb
opal-0.8.0.rc1 opal/corelib/io.rb
opal-0.8.0.beta1 opal/corelib/io.rb
opal-0.7.2 opal/corelib/io.rb
opal-0.7.1 opal/corelib/io.rb
opal-0.7.0 opal/corelib/io.rb
opal-0.7.0.rc1 opal/corelib/io.rb