るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

クラス

キーワード

検索結果

File::Stat#<=>(o) -> Integer | nil (3045.0)

ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。

...o File::Stat のインスタンスを指定します。

//emlist[][ruby]{
require
'tempfile' # for Tempfile

fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"

p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File:...
...:Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}...

File::Stat#symlink? -> false (3043.0)

シンボリックリンクである時に真を返します。 ただし、File::Statは自動的にシンボリックリンクをたどっていくので 常にfalseを返します。

...File::Statは自動的にシンボリックリンクをたどっていくので
常にfalseを返します。

//emlist[][ruby]{
require
'fileutils'
outfile = $0 + ".ln"
File
Utils.ln_s($0, outfile)
p File::Stat.new(outfile).symlink? #=> false
p File.lstat(outfile).symlink? #=> true
p FileTest...
....symlink?(outfile) #=> true
//}

@see File.lstat...

File::Stat#size? -> Integer | nil (3021.0)

サイズが0の時にはnil、それ以外の場合はファイルサイズを返します。

...はnil、それ以外の場合はファイルサイズを返します。

//emlist[][ruby]{
require
'tempfile'

fp = Tempfile.new("temp")
p fp.size #=> 0
p File::Stat.new(fp.path).size? #=> nil
fp.print "not 0 "
fp.close
p FileTest.exist?(fp.path) #=> true
p File::Stat.new(fp.path).size? #=> 6
//}...

LoadError#path -> String | nil (37.0)

Kernel.#require や Kernel.#load に失敗したパスを返します。

...Kernel.#require や Kernel.#load に失敗したパスを返します。

begin
require
'this/file/does/not/exist'
rescue LoadError => e
e.path # => 'this/file/does/not/exist'
end

パスが定まらない場合は nil を返します。...

Dir#read -> String | nil (21.0)

ディレクトリストリームから次の要素を読み出して返します。最後の要素 まで読み出していれば nil を返します。

...e IOError 既に自身が close している場合に発生します。

//emlist[例][ruby]{
require
'tmpdir'

Dir.mktmpdir do |tmpdir|
File
.open("#{tmpdir}/test1.txt", "w") { |f| f.puts("test1") }
File
.open("#{tmpdir}/test2.txt", "w") { |f| f.puts("test2") }
Dir.open(tmpdir) do |d|
p d.r...

絞り込み条件を変える

IO#fdatasync -> 0 (21.0)

IO のすべてのバッファされているデータを直ちにディスクに書き込みます。

...@raise NotImplementedError fdatasync(2) も fsync(2) も
サポートされていない OS で発生します。

//emlist[例][ruby]{
require
"tempfile"

Tempfile.open("testtmpfile") do |f|
f.print "test"
File
.read(f.path) # => ""
f.fdatasync
File
.read(f.path) # => "test"
end
//}...

IO#flush -> self (21.0)

IO ポートの内部バッファをフラッシュします。

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

@raise Errno::EXXX fflush(3) が失敗した場合に発生します。

//emlist[例][ruby]{
require
"tempfile"

Tempfile.open("testtmpfile") do |f|
f.print "test"
File
.read(f.path) # => ""
f.flush
File
.read(f.path) # => "test"
end
//}...

IO#fcntl(cmd, arg = 0) -> Integer (15.0)

IOに対してシステムコール fcntl を実行します。 機能の詳細は fcntl(2) を参照してください。 fcntl(2) が返した整数を返します。

...@raise IOError 既に close されている場合に発生します。

//emlist[例][ruby]{
require
"fcntl"

IO.write("testfile", "abcde")
# ファイル状態フラグを読み出す
File
.open("testfile") do |f|
f.fcntl(Fcntl::F_GETFL, 0) # => 0
f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) # =...