るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

<< 1 2 3 > >>

IO#path -> String | nil (26231.0)

IO に関連付けられたパスを返します。IO がパスに関連付けられていない場合は nil を返します。

...が返すパスがファイルシステム上に存在することは保証されていません。

//emlist[例][ruby]{
p STDIN.path # => "<STDIN>"
p IO.new(IO.sysopen("/")).path # => "/"
p IO.new(IO.sysopen("/"), path: "foo").path # => "foo"
//}...

LoadError#path -> String | nil (26211.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 を返します。...

File#path -> String (26147.0)

オープン時に使用したパスを文字列で返します。

...作成されていたりする場合です。

//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...
...発生します。

//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } # IOError: File is unnamed (TMPFILE?)
//}...

Dir#path -> String (26129.0)

オープンしているディレクトリのパス名を文字列で返します。

...オープンしているディレクトリのパス名を文字列で返します。

//emlist[例][ruby]{
Dir.open("..") do |d|
d.path # => ".."
d.to_path # => ".."
end
//}...

TracePoint#path -> String (26128.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
//}...

絞り込み条件を変える

IO#to_path -> String | nil (14231.0)

IO に関連付けられたパスを返します。IO がパスに関連付けられていない場合は nil を返します。

...が返すパスがファイルシステム上に存在することは保証されていません。

//emlist[例][ruby]{
p STDIN.path # => "<STDIN>"
p IO.new(IO.sysopen("/")).path # => "/"
p IO.new(IO.sysopen("/"), path: "foo").path # => "foo"
//}...

RubyVM::InstructionSequence#absolute_path -> String | nil (14223.0)

self が表す命令シーケンスの絶対パスを返します。

...ompiled>>
iseq.absolute_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello
puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@...
...see RubyVM::InstructionSequence#path...

File#to_path -> String (14147.0)

オープン時に使用したパスを文字列で返します。

...作成されていたりする場合です。

//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...
...発生します。

//emlist[例][ruby]{
File.open("testfile") {|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } # IOError: File is unnamed (TMPFILE?)
//}...

Thread::Backtrace::Location#absolute_path -> String (14146.0)

self が表すフレームの絶対パスを返します。

...][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.absolute_path
end

# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.rb
//}

@see Thread::Backtrace::Location#path...

Dir#to_path -> String (14129.0)

オープンしているディレクトリのパス名を文字列で返します。

...オープンしているディレクトリのパス名を文字列で返します。

//emlist[例][ruby]{
Dir.open("..") do |d|
d.path # => ".."
d.to_path # => ".."
end
//}...

絞り込み条件を変える

Exception#set_backtrace(errinfo) -> nil | String | [String] (8217.0)

バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。

...定します。

//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
$!.backtrace # => ["/path/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.set_backtrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end
//}...
<< 1 2 3 > >>