るりまサーチ (Ruby 2.4.0)

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

別のキーワード

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

ライブラリ

キーワード

検索結果

IO#readlines(limit, chomp: false) -> [String] (18793.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] (18793.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] (18793.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] (18793.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] (18793.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] (18793.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#readline(limit, chomp: false) -> String (18649.0)

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

...が発生します。

テキスト読み込みメソッドとして動作します。

読み込んだ文字列を変数 $_ にセットします。IO#gets との違いは EOF での振る舞いのみです。

limit で最大読み込みバイト数を指定します。ただしマルチバイト...
...と各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise EOFError EOF に到達した時に発生します。

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

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

@see $/, IO#gets...

IO#readline(rs = $/, chomp: false) -> String (18649.0)

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

...が発生します。

テキスト読み込みメソッドとして動作します。

読み込んだ文字列を変数 $_ にセットします。IO#gets との違いは EOF での振る舞いのみです。

limit で最大読み込みバイト数を指定します。ただしマルチバイト...
...と各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise EOFError EOF に到達した時に発生します。

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

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

@see $/, IO#gets...

IO#readline(rs, limit, chomp: false) -> String (18649.0)

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

...が発生します。

テキスト読み込みメソッドとして動作します。

読み込んだ文字列を変数 $_ にセットします。IO#gets との違いは EOF での振る舞いのみです。

limit で最大読み込みバイト数を指定します。ただしマルチバイト...
...と各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

@raise EOFError EOF に到達した時に発生します。

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

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

@see $/, IO#gets...

IO.write(path, string, **opts) -> Integer (466.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...キーワード引数はファイルを開くときに使われ、エンコーディングなどを指定することができます。
詳しくは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@par...
...s line three\nAnd so on...\n"
IO
.write("testfile", text) # => 66
IO
.write("testfile", "0123456789", 20) #=> 10
IO
.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO
.write("testfile", "0123456789") #=> 10
IO
.read("testfile")...
...# => "0123456789"
//}

@see IO.binwrite...

絞り込み条件を変える

IO.write(path, string, offset=nil, **opts) -> Integer (466.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...キーワード引数はファイルを開くときに使われ、エンコーディングなどを指定することができます。
詳しくは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@par...
...s line three\nAnd so on...\n"
IO
.write("testfile", text) # => 66
IO
.write("testfile", "0123456789", 20) #=> 10
IO
.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO
.write("testfile", "0123456789") #=> 10
IO
.read("testfile")...
...# => "0123456789"
//}

@see IO.binwrite...

IO.binread(path, length = nil, offset = 0) -> String | nil (451.0)

path で指定したファイルを open し、offset の所まで seek し、 length バイト読み込みます。

...ist[例][ruby]{
IO
.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...\n")
IO
.binread("testfile") # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO
.binread("testfile", 20) # => "This is line one\nThi"
IO
.binread("test...
...file", 20, 10) # => "ne one\nThis is line "
//}

@see IO.read...

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

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

...il を返します。

テキスト読み込みメソッドとして動作します。

読み込んだ文字列を変数 $_ にセットします。
IO
#readline との違いは EOF での振る舞いのみです。

limit で最大の読み込みバイト数を指定します。ただし
ファイ...
...の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

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

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

@see $/, IO#readline...

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

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

...il を返します。

テキスト読み込みメソッドとして動作します。

読み込んだ文字列を変数 $_ にセットします。
IO
#readline との違いは EOF での振る舞いのみです。

limit で最大の読み込みバイト数を指定します。ただし
ファイ...
...の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

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

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

@see $/, IO#readline...

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

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

...il を返します。

テキスト読み込みメソッドとして動作します。

読み込んだ文字列を変数 $_ にセットします。
IO
#readline との違いは EOF での振る舞いのみです。

limit で最大の読み込みバイト数を指定します。ただし
ファイ...
...の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。

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

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

@see $/, IO#readline...

絞り込み条件を変える