String
# File lib/websocket/frame/data.rb, line 9 def <<(*args) super(*convert_args(args)) end
Convert all arguments to ASCII-8BIT for easier traversing
# File lib/websocket/frame/data.rb, line 14 def convert_args(args) args.each { |arg| arg.force_encoding('ASCII-8BIT') } end
Extract `count` bytes starting from `start_index` and unmask it if needed.
# File lib/websocket/frame/data.rb, line 30 def getbytes(start_index, count) data = self[start_index, count] data = mask(data.bytes.to_a, @masking_key).pack('C*') if @masking_key data end
Mask whole payload using mask key
# File lib/websocket/frame/data.rb, line 37 def mask(payload, mask) return mask_native(payload, mask) if respond_to?(:mask_native) result = [] payload.each_with_index do |byte, i| result[i] = byte ^ mask[i % 4] end result end
Generated with the Darkfish Rdoc Generator 2.