Class: DRb::WebSocket::StrStream
- Inherits:
-
Object
- Object
- DRb::WebSocket::StrStream
- Defined in:
- lib/opal/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.
60 61 62 |
# File 'lib/opal/drb/websocket.rb', line 60 def initialize(str='') @buf = str end |
Instance Attribute Details
#buf ⇒ Object (readonly)
Returns the value of attribute buf.
63 64 65 |
# File 'lib/opal/drb/websocket.rb', line 63 def buf @buf end |
Instance Method Details
#read(n) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/opal/drb/websocket.rb', line 65 def read(n) begin return @buf[0,n] ensure @buf = @buf[n, @buf.size - n] end end |
#write(s) ⇒ Object
73 74 75 |
# File 'lib/opal/drb/websocket.rb', line 73 def write(s) @buf += s end |