るりまサーチ

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

別のキーワード

  1. kernel test
  2. _builtin test
  3. rubygems/test_utilities fetcher=
  4. rubygems/test_utilities tempio
  5. testtask test_files=

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

TracePoint#path -> String (18121.0)

イベントが発生したファイルのパスを返します。

...トが発生したファイルのパスを返します。

@raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end
trace.enable
foo 1
//}...

FileTest.#world_readable?(path) -> Integer | nil (3125.0)

path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。

...
path
が全てのユーザから読めるならばそのファイルのパーミッションを表す
整数を返します。そうでない場合は nil を返します。

整数の意味はプラットフォームに依存します。

@param path パスを表す文字列を指定します。...
...m = FileTest.world_readable?("/etc/passwd")
"%o" % m # => "644"...

FileTest.#world_writable?(path) -> bool (3125.0)

path が全てのユーザから書き込めるならば、そのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。

...
path
が全てのユーザから書き込めるならば、そのファイルのパーミッションを表す
整数を返します。そうでない場合は nil を返します。

整数の意味はプラットフォームに依存します。

@param path パスを表す文字列を指定し...
...ます。

m = FileTest.world_writable?("/tmp")
"%o" % m #=> "777"...

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (158.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
test
1(start, length)
end

def test3(start, length)
test
2(start, length)
end

caller_locations # => []
test
3(1, nil)
#...
.../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test
3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9...
..., 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test
3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (158.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
test
1(start, length)
end

def test3(start, length)
test
2(start, length)
end

caller_locations # => []
test
3(1, nil)
#...
.../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test
3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9...
..., 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test
3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

絞り込み条件を変える

File.new(path, mode = "r", perm = 0666) -> File (145.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...
path
で指定されるファイルをオープンし、File オブジェクトを生成して
返します。

path
が整数の場合はファイルディスクリプタとして扱い、それに対応する
File オブジェクトを生成して返します。IO.open と同じです。
ブロ...
...ロックの実行が終了すると、ファイルは自動的に
クローズされます。ブロックの実行結果を返します。

@param path ファイルを文字列で指定します。整数を指定した場合はファイルディスクリプタとして扱います。

@param mode...
...み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open に...

File.open(path, mode = "r", perm = 0666) -> File (145.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...
path
で指定されるファイルをオープンし、File オブジェクトを生成して
返します。

path
が整数の場合はファイルディスクリプタとして扱い、それに対応する
File オブジェクトを生成して返します。IO.open と同じです。
ブロ...
...ロックの実行が終了すると、ファイルは自動的に
クローズされます。ブロックの実行結果を返します。

@param path ファイルを文字列で指定します。整数を指定した場合はファイルディスクリプタとして扱います。

@param mode...
...み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open に...

File.open(path, mode = "r", perm = 0666) {|file| ... } -> object (145.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...
path
で指定されるファイルをオープンし、File オブジェクトを生成して
返します。

path
が整数の場合はファイルディスクリプタとして扱い、それに対応する
File オブジェクトを生成して返します。IO.open と同じです。
ブロ...
...ロックの実行が終了すると、ファイルは自動的に
クローズされます。ブロックの実行結果を返します。

@param path ファイルを文字列で指定します。整数を指定した場合はファイルディスクリプタとして扱います。

@param mode...
...み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open に...

File.readlink(path) -> String (121.0)

シンボリックリンクのリンク先のパスを文字列で返します。

...@param path シンボリックリンクを表す文字列を指定します。

@raise Errno::EXXX 指定された path がシンボリックリンクでない場合や、リンクの読み取りに失敗した場合に発生します。

//emlist[例:][ruby]{
IO.write("testfile", "test")
File.sym...
...link("testfile", "testlink") # => 0
File.readlink("testlink") # => "testfile"
//}...
<< 1 2 > >>