るりまサーチ

最速Rubyリファレンスマニュアル検索!
75件ヒット [1-75件を表示] (0.145秒)
トップページ > クエリ:i[x] > クエリ:h[x] > クエリ:to_path[x]

別のキーワード

  1. _builtin to_h
  2. env to_h
  3. hash to_h
  4. array to_h
  5. struct to_h

ライブラリ

クラス

キーワード

検索結果

Dir#to_path -> String (24307.0)

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

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

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

File#to_path -> String (24301.0)

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

...
File::Constants::TMPFILEオプション付きで作成されていたりする場合です。

//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::R...
...DWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...
...raise IOError TMPFILE File::Constants::TMPFILEオプション付きで作成されている場合に発生します。

//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?)
//}...

IO#to_path -> String | nil (24301.0)

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

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

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

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

Pathname#to_path -> String (24301.0)

File.open などの引数に渡す際に呼ばれるメソッドです。 Pathname オブジェ クトにおいては、 to_s と同じです。

...File.open などの引数に渡す際に呼ばれるメソッドです。 Pathname オブジェ
クトにおいては、 to_s と同じです。


@see Pathname#to_s...

File.path(filename) -> String (9228.0)

指定されたファイル名を文字列で返します。filename が文字列でない場合は、to_path メソッドを呼びます。

...filename が文字列でない場合は、to_path メソッドを呼びます。

@param filename ファイル名を表す文字列か to_path メソッドが定義されたオブジェクトを指定します。

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

class MyPath
def initialize(path)
@path...
...= path
end
def to_path
File.absolute_path(@path)
end
end

File.path("/dev/null") # => "/dev/null"
File.path(Pathname("/tmp")) # => "/tmp"
File.path(MyPath.new(".")) # => "/Users/user/projects/txt"
//}...

絞り込み条件を変える

Dir#path -> String (9207.0)

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

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

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

File.absolute_path?(file_name) -> bool (9206.0)

file_name が絶対パスなら true を、そうでなければ false を返します。

...file_name が絶対パスなら true を、そうでなければ false を返します。

@param file_name ファイル名を表す文字列を指定します。文字列でない場合は、to_path メソッド、to_str メソッドの順で暗黙の型変換が試みられます。

@raise TypeE...
.../emlist[例][ruby]{
File.absolute_path?("//foo/bar\\baz") # => true
File.absolute_path?("C:foo\\bar") # => false
File.absolute_path?("~") # => false

# プラットフォームが cygwin、mswin、mingw の場合
File.absolute_path?("C:\\foo\\bar") # => true
File.absolute_path?("/...
...foo/bar\\baz") # => false

# プラットフォームが上記以外の場合
File.absolute_path?("C:\\foo\\bar") # => false
File.absolute_path?("/foo/bar\\baz") # => true
//}...

File#path -> String (9201.0)

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

...
File::Constants::TMPFILEオプション付きで作成されていたりする場合です。

//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::R...
...DWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...
...raise IOError TMPFILE File::Constants::TMPFILEオプション付きで作成されている場合に発生します。

//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?)
//}...

IO#path -> String | nil (9201.0)

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

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

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

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