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.



139
140
141
# File 'lib/opal/drb/websocket.rb', line 139

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

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf.



142
143
144
# File 'lib/opal/drb/websocket.rb', line 142

def buf
  @buf
end

Instance Method Details

#read(n) ⇒ Object



144
145
146
147
148
149
150
# File 'lib/opal/drb/websocket.rb', line 144

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

#write(s) ⇒ Object



152
153
154
# File 'lib/opal/drb/websocket.rb', line 152

def write(s)
  @buf += s
end