Class: DRb::DRbWebSocket::StrStream
- Inherits:
-
Object
- Object
- DRb::DRbWebSocket::StrStream
- Defined in:
- lib/drb/drb_websocket.rb
Instance Attribute Summary collapse
-
#buf ⇒ Object
readonly
Returns the value of attribute buf.
Instance Method Summary collapse
-
#initialize(str = '') ⇒ StrStream
constructor
A new instance of StrStream.
- #read(n) ⇒ Object
- #write(s) ⇒ Object
Constructor Details
#initialize(str = '') ⇒ StrStream
Returns a new instance of StrStream.
59 60 61 |
# File 'lib/drb/drb_websocket.rb', line 59 def initialize(str='') @buf = str end |
Instance Attribute Details
#buf ⇒ Object (readonly)
Returns the value of attribute buf.
62 63 64 |
# File 'lib/drb/drb_websocket.rb', line 62 def buf @buf end |
Instance Method Details
#read(n) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/drb/drb_websocket.rb', line 64 def read(n) begin return @buf[0,n] ensure @buf = @buf[n, @buf.size - n] end end |
#write(s) ⇒ Object
72 73 74 |
# File 'lib/drb/drb_websocket.rb', line 72 def write(s) @buf += s end |