Class: Baykit::BayServer::Rudders::IORudder
- Inherits:
-
Object
- Object
- Baykit::BayServer::Rudders::IORudder
- Includes:
- Rudder
- Defined in:
- lib/baykit/bayserver/rudders/io_rudder.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#non_blocking ⇒ Object
readonly
Returns the value of attribute non_blocking.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(io) ⇒ IORudder
constructor
A new instance of IORudder.
- #key ⇒ Object
- #read(buf, len) ⇒ Object
- #set_non_blocking ⇒ Object
- #to_s ⇒ Object
- #write(buf) ⇒ Object
Constructor Details
#initialize(io) ⇒ IORudder
Returns a new instance of IORudder.
12 13 14 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 12 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
9 10 11 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 9 def io @io end |
#non_blocking ⇒ Object (readonly)
Returns the value of attribute non_blocking.
10 11 12 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 10 def non_blocking @non_blocking end |
Instance Method Details
#close ⇒ Object
52 53 54 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 52 def close @io.close() end |
#key ⇒ Object
19 20 21 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 19 def key return @io end |
#read(buf, len) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 27 def read(buf, len) begin if @non_blocking buf = @io.read_nonblock(len, buf) else buf = @io.readpartial(len, buf) end if buf == nil return 0 else return buf.length end rescue EOFError => e return 0 end end |
#set_non_blocking ⇒ Object
23 24 25 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 23 def set_non_blocking() @non_blocking = true end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 16 def to_s return "IORudder:" + @io.to_s end |
#write(buf) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/baykit/bayserver/rudders/io_rudder.rb', line 44 def write(buf) if @non_blocking return @io.write_nonblock(buf) else return @io.write(buf) end end |