LoginSignup
0
0

More than 5 years have passed since last update.

Ruby IOクラス

Posted at
1 / 2

IOクラス

  • FileクラスのSuperClass
  • 入出力機能を備えたクラス

IOからの入力

  • IO.read / read
  • IO.foreach / each / each_lines
    • 指定されたファイルを開き、各行をブロックに渡して実行していく。
  • readlines
    • 全てのファイルを読み込んで、配列を返す。
  • readline / gets
  • each_byte
  • getbyte / readbyte
  • each_char
  • getc / readchar

IOへの出力

  • wrire
  • puts
  • print
  • printf
  • putc
  • flush

IOの状態

  • stat
  • closed?
  • eof / eof?
  • lineno
    • getsメソッドが呼び出された回数
  • sync

ファイルポインタの移動・設定

  • rewind
    • ファイルポインタを先頭に移動し、linenoの値を0に設定。
  • pos
    • ファイルポインタの位置を取得・設定
  • seek
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0