Sha256: 0ad4733012df21d8b1de3ed66b6e36e37fdde66e047254f3e7c01dbc789a1ec6
Contents?: true
Size: 818 Bytes
Versions: 3
Compression:
Stored size: 818 Bytes
Contents
module IRuby # IO-like object that publishes to 0MQ socket. class OStream def initialize(session, socket, name) @session = session @socket = socket @name = name end def close @socket = nil end def flush end def isatty false end alias_method :tty?, :isatty def read(*args) raise IOError, 'not opened for reading' end alias_method :next, :read alias_method :readline, :read def write(s) raise 'I/O operation on closed file' unless @socket @session.send(@socket, 'stream', { name: @name, data: s.to_s }) nil end alias_method :<<, :write alias_method :print, :write def puts(s) write "#{s}\n" end def writelines(lines) lines.each { |s| write(s) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
iruby-0.1.13 | lib/iruby/ostream.rb |
iruby-0.1.12 | lib/iruby/ostream.rb |
iruby-0.1.11 | lib/iruby/ostream.rb |