require 'stringio' def fifth_byte(file) file.seek(5) file.read(1) end fifth_byte(StringIO.new("123456")) # => "6"