class WebSocket::Driver::Hybi::StreamReader

Public Class Methods

new() click to toggle source
# File lib/websocket/driver/hybi/stream_reader.rb, line 6
def initialize
  @queue = []
end

Public Instance Methods

put(bytes) click to toggle source
# File lib/websocket/driver/hybi/stream_reader.rb, line 14
def put(bytes)
  return unless bytes and bytes.size > 0
  @queue.concat(bytes)
end
read(length) click to toggle source
# File lib/websocket/driver/hybi/stream_reader.rb, line 10
def read(length)
  read_bytes(length)
end

Private Instance Methods

read_bytes(length) click to toggle source
# File lib/websocket/driver/hybi/stream_reader.rb, line 21
def read_bytes(length)
  return nil if length > @queue.size
  @queue.shift(length)
end