Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > IOクラス > ungetc
ungetc(char) -> nil指定された char を読み戻します。 2バイト以上の読み戻しは保証されません。
f = File.new("testfile") #=> #<File:testfile>
c = f.getc #=> 84
f.ungetc(c) #=> nil
f.getc #=> 84