るりまサーチ

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

別のキーワード

  1. ri generate
  2. ri description
  3. rdoc/generator/ri initialize
  4. rdoc/generator/ri ri

ライブラリ

検索結果

File.path(filename) -> String (107.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"
//}...