Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > IOクラス > ungetc
ungetc(char) -> nil[permalink][rdoc]指定された char を読み戻します。
f = File.new("testfile") # => #<File:testfile>
c = f.getc # => "い"
f.ungetc(c) # => nil
f.getc # => "い"