Class: DRb::WebSocket::StrStream

Inherits:
Object
  • Object
show all
Defined in:
lib/drb/websocket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str = '') ⇒ StrStream

Returns a new instance of StrStream.



8
9
10
# File 'lib/drb/websocket.rb', line 8

def initialize(str='')
  @buf = str
end

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf.



11
12
13
# File 'lib/drb/websocket.rb', line 11

def buf
  @buf
end

Instance Method Details

#read(n) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/drb/websocket.rb', line 13

def read(n)
  begin
    return @buf[0,n]
  ensure
    @buf[0,n] = ''
  end
end

#write(s) ⇒ Object



21
22
23
# File 'lib/drb/websocket.rb', line 21

def write(s)
  @buf.concat s
end