Class: DRb::WebSocket::StrStream

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bufObject (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