# frozen_string_literal: true require 'forwardable' module Steam # Reads bytes from a given IO object. class ByteReader extend Forwardable # Create a ByteReader object # # @param io [:read] an io object def initialize(io) @io = io end # Reads a string of a given length from the stream # # @param len [Integer] the number of bytes to read # @return [String] The read string def string(len) read(len) end # Reads an unsigned 32 bit integer from the stream # # @return [Integer] The 32 bit integer def unsigned_int32 @io.read(4).unpack('