gets(rs = $/, chomp: false) -> String | nil
[permalink][rdoc]gets(limit, chomp: false) -> String | nil
gets(rs, limit, chomp: false) -> String | nil
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時には nil を返します。
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt # $ ruby test.rb test.txt # test.rb ARGF.gets # => "line1\n"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt # $ ruby test.rb test.txt # test.rb ARGF.gets(2) # => "li"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt # $ ruby test.rb test.txt # test.rb ARGF.gets("e") # => "line"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt # $ ruby test.rb test.txt # test.rb ARGF.gets("") # => "line1\nline2\nline3\n\n"
[SEE_ALSO] Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc