Ruby 3.3 リファレンスマニュアル

instance method IO#getbyte

getbyte -> Integer | nil[permalink][rdoc][edit]

IO から1バイトを読み込み整数として返します。既に EOF に達していれば nil を返します。

f = File.new("testfile")
p f.getbyte #=> 84
p f.getbyte #=> 104