るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.057秒)
トップページ > クラス:IO[x] > ライブラリ:ビルトイン[x] > バージョン:2.4.0[x] > クエリ:string[x] > クエリ:lines[x]

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub!

検索結果

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

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

...@param chomp true を指定すると各行の末尾から rs を取り除きます。

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

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }...
...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] (18619.0)

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

...@param chomp true を指定すると各行の末尾から rs を取り除きます。

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

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }...
...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] (18619.0)

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

...@param chomp true を指定すると各行の末尾から rs を取り除きます。

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

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }...
...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(path, limit, chomp: false, opts={}) -> [String] (18619.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile",...
..."line1,\rline2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...

IO.readlines(path, rs = $/, chomp: false, opts={}) -> [String] (18619.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile",...
..."line1,\rline2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...

絞り込み条件を変える

IO.readlines(path, rs, limit, chomp: false, opts={}) -> [String] (18619.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile",...
..."line1,\rline2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...