るりまサーチ

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

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file lstat
  4. file size
  5. file path

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Kernel#file(*args) { ... } -> Rake::FileTask (24421.0)

ファイルタスクを定義します。

...ル名と依存ファイル名を指定します。

例:
file
"config.cfg" => ["config.template"] do
open("config.cfg", "w") do |outfile|
open("config.template") do |infile|
while line = infile.gets
outfile.puts line
end
end
end
end

@see R...

IRB::FileInputMethod#gets -> String (24102.0)

読み込んだファイルから文字列を 1 行読み込みます。

読み込んだファイルから文字列を 1 行読み込みます。

IO#gets(limit) -> String | nil (18140.0)

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

...み用にオープンされていなければ発生します。

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

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

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

...み用にオープンされていなければ発生します。

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

IO#gets(rs = $/) -> String | nil (18140.0)

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

...み用にオープンされていなければ発生します。

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

絞り込み条件を変える

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

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

...み用にオープンされていなければ発生します。

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

IO#gets(rs, limit) -> String | nil (18140.0)

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

...み用にオープンされていなければ発生します。

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

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

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

...み用にオープンされていなければ発生します。

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

Tempfile#delete -> self (6007.0)

テンポラリファイルをクローズせずに、削除します。 UNIXライクなシステムでは、 作成したテンポラリファイルが他のプログラムに使用される機会をなくすために、 テンポラリファイルを作成しオープンした後、 すぐに削除するということがしばしばおこなわれます。

...ンポラリファイルを作成しオープンした後、
すぐに削除するということがしばしばおこなわれます。


require "tempfile"
tf = Tempfile.new("foo")
tf.unlink
p tf.path # => nil
tf.print("foobar,hoge\n")
tf.rewind
p tf.gets("\n") # => "foobar,hoge\n"...

Tempfile#open -> self (6007.0)

クローズしたテンポラリファイルを再オープンします。 "r+" でオープンされるので、クローズ前の内容を再度読む ことができます。

...ァイルを再オープンします。
"r+" でオープンされるので、クローズ前の内容を再度読む
ことができます。

require "tempfile"
tf = Tempfile.new("foo")
tf.print("foobar,hoge\n")
tf.print("bar,ugo\n")
tf.close
tf.open
p tf.gets # => "foobar,hoge\n"...

絞り込み条件を変える

Tempfile#unlink -> self (6007.0)

テンポラリファイルをクローズせずに、削除します。 UNIXライクなシステムでは、 作成したテンポラリファイルが他のプログラムに使用される機会をなくすために、 テンポラリファイルを作成しオープンした後、 すぐに削除するということがしばしばおこなわれます。

...ンポラリファイルを作成しオープンした後、
すぐに削除するということがしばしばおこなわれます。


require "tempfile"
tf = Tempfile.new("foo")
tf.unlink
p tf.path # => nil
tf.print("foobar,hoge\n")
tf.rewind
p tf.gets("\n") # => "foobar,hoge\n"...

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

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

...uby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File
.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File
.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File
.open("testfile") { |f| p f.readlin...
...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...
<< 1 2 3 ... > >>