Class: IRuby::OStream
- Inherits:
-
Object
- Object
- IRuby::OStream
- Defined in:
- lib/iruby/ostream.rb
Overview
IO-like object that publishes to 0MQ socket.
Instance Attribute Summary collapse
-
#sync ⇒ Object
Returns the value of attribute sync.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #flush ⇒ Object
-
#initialize(session, name) ⇒ OStream
constructor
A new instance of OStream.
- #isatty ⇒ Object (also: #tty?)
- #printf(format, *obj) ⇒ Object
- #puts(*obj) ⇒ Object
- #read(*args) ⇒ Object (also: #next, #readline)
-
#set_encoding(extern, intern) ⇒ Object
Called by irb.
- #write(*obj) ⇒ Object (also: #<<, #print)
- #writelines(lines) ⇒ Object
Constructor Details
#initialize(session, name) ⇒ OStream
Returns a new instance of OStream.
6 7 8 |
# File 'lib/iruby/ostream.rb', line 6 def initialize(session, name) @session, @name = session, name end |
Instance Attribute Details
#sync ⇒ Object
Returns the value of attribute sync.
4 5 6 |
# File 'lib/iruby/ostream.rb', line 4 def sync @sync end |
Instance Method Details
#close ⇒ Object
10 11 12 |
# File 'lib/iruby/ostream.rb', line 10 def close @session = nil end |
#closed? ⇒ Boolean
14 15 16 |
# File 'lib/iruby/ostream.rb', line 14 def closed? @session.nil? end |
#flush ⇒ Object
18 19 |
# File 'lib/iruby/ostream.rb', line 18 def flush end |
#isatty ⇒ Object Also known as: tty?
21 22 23 |
# File 'lib/iruby/ostream.rb', line 21 def isatty false end |
#printf(format, *obj) ⇒ Object
39 40 41 42 |
# File 'lib/iruby/ostream.rb', line 39 def printf(format, *obj) str = build_string { |sio| sio.printf(format, *obj) } session_send(str) end |
#puts(*obj) ⇒ Object
44 45 46 47 |
# File 'lib/iruby/ostream.rb', line 44 def puts(*obj) str = build_string { |sio| sio.puts(*obj) } session_send(str) end |
#read(*args) ⇒ Object Also known as: next, readline
26 27 28 |
# File 'lib/iruby/ostream.rb', line 26 def read(*args) raise IOError, 'not opened for reading' end |
#set_encoding(extern, intern) ⇒ Object
Called by irb
54 55 56 |
# File 'lib/iruby/ostream.rb', line 54 def set_encoding(extern, intern) extern end |
#write(*obj) ⇒ Object Also known as: <<, print
32 33 34 35 |
# File 'lib/iruby/ostream.rb', line 32 def write(*obj) str = build_string { |sio| sio.write(*obj) } session_send(str) end |
#writelines(lines) ⇒ Object
49 50 51 |
# File 'lib/iruby/ostream.rb', line 49 def writelines(lines) lines.each { |s| write(s) } end |