るりまサーチ

最速Rubyリファレンスマニュアル検索!
192件ヒット [1-100件を表示] (0.265秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

ARGF.class#gets(limit, chomp: false) -> String | nil (26145.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...大の読み込みバイト数

@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
#...
...F.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 Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

ARGF.class#gets(rs = $/, chomp: false) -> String | nil (26145.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...大の読み込みバイト数

@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
#...
...F.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 Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

ARGF.class#gets(rs, limit, chomp: false) -> String | nil (26145.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...大の読み込みバイト数

@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets # => "line1\n"

例:
#...
...F.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 Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

IO#gets(limit, chomp: false) -> String | nil (26121.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "T...
...his is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil

@see $/, IO#readline...

IO#gets(rs = $/, chomp: false) -> String | nil (26121.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "T...
...his is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil

@see $/, IO#readline...

絞り込み条件を変える

IO#gets(rs, limit, chomp: false) -> String | nil (26121.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "T...
...his is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil

@see $/, IO#readline...

IO#readlines(limit, chomp: false) -> [String] (8030.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から rs を取り除きます。

@raise IOError 自身が読み込み用にオープンされていなければ...
...chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}

@see $/, IO#gets...

IO#readlines(rs = $/, chomp: false) -> [String] (8030.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から rs を取り除きます。

@raise IOError 自身が読み込み用にオープンされていなければ...
...chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}

@see $/, IO#gets...

IO#readlines(rs, limit, chomp: false) -> [String] (8030.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から rs を取り除きます。

@raise IOError 自身が読み込み用にオープンされていなければ...
...chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}

@see $/, IO#gets...

IO#each(limit, chomp: false) -> Enumerator (8024.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープ...
...li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This...
...is line two"
# "3: This is line three"
# "4: And so on..."
//}

@see $/, IO#gets...

絞り込み条件を変える

IO#each(limit, chomp: false) {|line| ... } -> self (8024.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープ...
...li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This...
...is line two"
# "3: This is line three"
# "4: And so on..."
//}

@see $/, IO#gets...

IO#each(rs = $/, chomp: false) -> Enumerator (8024.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープ...
...li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This...
...is line two"
# "3: This is line three"
# "4: And so on..."
//}

@see $/, IO#gets...

IO#each(rs = $/, chomp: false) {|line| ... } -> self (8024.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...と連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise IOError 自身が読み込み用にオープ...
...li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This...
...is line two"
# "3: This is line three"
# "4: And so on..."
//}

@see $/, IO#gets...
<< 1 2 > >>