lib/http/2/buffer.rb in http-2-0.7.0 vs lib/http/2/buffer.rb in http-2-0.8.0

- old
+ new

@@ -1,29 +1,26 @@ module HTTP2 - # Simple binary buffer backed by string. # class Buffer < String + UINT32 = 'N'.freeze + private_constant :UINT32 - UINT32 = "N" - BINARY = "binary" - private_constant :UINT32, :BINARY - # Forces binary encoding on the string - def initialize(data = '') - super(data.force_encoding(BINARY)) + def initialize(*) + super.force_encoding(Encoding::BINARY) end # Emulate StringIO#read: slice first n bytes from the buffer. # # @param n [Integer] number of bytes to slice from the buffer def read(n) - Buffer.new(slice!(0,n)) + Buffer.new(slice!(0, n)) end # Alias getbyte to readbyte - alias :readbyte :getbyte + alias_method :readbyte, :getbyte # Emulate StringIO#getbyte: slice first byte from buffer. def getbyte read(1).ord end @@ -32,7 +29,6 @@ # @return [Integer] def read_uint32 read(4).unpack(UINT32).first end end - end