るりまサーチ

最速Rubyリファレンスマニュアル検索!
49件ヒット [1-49件を表示] (0.036秒)
トップページ > クラス:File[x] > クエリ:to_path[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

キーワード

検索結果

File#to_path -> String (15104.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"
//}...
...Error 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?)
//}...

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

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

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

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

//emlist[例][ruby]{
requ...
...ire '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"
//}...

File.absolute_path?(file_name) -> bool (9.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.join(*item) -> String (9.0)

File::SEPARATORを間に入れて文字列を連結します。platform/DOSISH-supportで環境依存になる予定です。

...
File
::SEPARATORを間に入れて文字列を連結します。platform/DOSISH-supportで環境依存になる予定です。

@param item 連結したいディレクトリ名やファイル名を文字列(もしくは文字列を要素に持つ配列)で与えます。
文字列A...
...とBを連結する際に、Aの末尾の文字とBの先頭の文字がFile::SEPARATORであった場合には、
まずこれらを削除した上で改めてFile::SEPARATORを間に入れて連結します。
引数の中に配列がある場合は配列要素を再帰的...
...に変換されます。
配列・文字列以外のオブジェクトを指定した場合は、まず to_str メソッド、次に to_path メソッドにより暗黙の型変換を試みます。
引数がない場合には空文字列を生成して返します。

@raise...

File#path -> String (4.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"
//}...
...Error 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?)
//}...

絞り込み条件を変える