るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.212秒)
トップページ > クエリ:-[x] > クエリ:r[x] > クエリ:at[x] > クエリ:l[x] > クエリ:require[x] > クエリ:expand_path[x]

別のキーワード

  1. _builtin at
  2. _builtin values_at
  3. time at
  4. dbm values_at
  5. csv values_at

ライブラリ

クラス

モジュール

検索結果

Kernel.#require_relative(relative_feature) -> bool (31253.0)

現在のファイルからの相対パスで require します。

...相対パスで require します。

require
File.expand_path(relative_feature, File.dirname(__FILE__))
とほぼ同じです。

Kernel.#eval などで文字列を評価した場合に、そこから
require
_relative を呼出すと必ず失敗します。

@param relative_feature ファイル...
...名の文字列です。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require

=== require load のスコープ

ローカル変数はファイル間では共有されません。ですので、
ロードしたライブラリのローカル変数を
ロード...
...扱い方はKernel.#loadでも同様です。

//emlist[例][ruby]{
# ---------- some.rb -----------
$a = 1
@a = 1
A = 1
a = 1
# ---------- end some.rb -------

require
'some'
p $a #=> 1
p @a #=> 1
p A #=> 1
p a # undefined local variable or method `a' for #<Object:0x294f9ec @a=1> (NameError)
//}...

Pathname#expand_path(default_dir = &#39;.&#39;) -> Pathname (27641.0)

Pathname.new(File.expand_path(self.to_s, *args)) と同じです。

...Pathname.new(File.expand_path(self.to_s, *args)) と同じです。

@param default_dir self が相対パスであれば default_dir を基準に展開されます。

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

path = Pathname("testfile")
Pathname.pwd # => #<Pathname:/path/to>
path.expand_...
...path # => #<Pathname:/path/to/testfile>
path.expand_path("../") # => #<Pathname:/path/testfile>
//}

@see File.expand_path...