種類
- 特異メソッド (44)
- インスタンスメソッド (23)
- 文書 (22)
- モジュール関数 (11)
ライブラリ
- ビルトイン (55)
- pathname (11)
- shell (6)
-
shell
/ command-processor (6)
クラス
- Dir (22)
- File (22)
- Pathname (11)
- Shell (6)
-
Shell
:: CommandProcessor (6)
モジュール
- Kernel (11)
キーワード
- DOSISH 対応 (11)
-
absolute
_ path (11) - home (22)
-
require
_ relative (11) - 変数と定数 (11)
検索結果
先頭5件
-
File
. expand _ path(path , default _ dir = & # 39; . & # 39;) -> String (24325.0) -
path を絶対パスに展開した文字列を返します。 path が相対パスであれば default_dir を基準にします。
...path が相対パスであれば default_dir を基準にします。
先頭の ~ はホームディレクトリ(環境変数 HOME が使われます)に、
~USER はそのユーザのホームディレクトリに展開されます。
//emlist[例][ruby]{
p Dir.getwd #=> "/ho......home/matz"
p File.expand_path("..") #=> "/home/matz/work"
p File.expand_path("..", "/tmp") #=> "/"
p File.expand_path("~") #=> "/home/matz"
p File.expand_path("~foo") #=> "/home/foo"
//}
@param path パスを表す文字列を指定します。
@param default_dir path が相......対パスであれば default_dir を基準に展開されます。... -
Shell
# expand _ path(path) -> String (21207.0) -
Fileクラスにある同名のクラスメソッドと同じです.
...Fileクラスにある同名のクラスメソッドと同じです.
@param path ファイル名を表す文字列を指定します。
@see File.expand_path... -
Shell
:: CommandProcessor # expand _ path(path) -> String (21207.0) -
Fileクラスにある同名のクラスメソッドと同じです.
...Fileクラスにある同名のクラスメソッドと同じです.
@param path ファイル名を表す文字列を指定します。
@see File.expand_path... -
Pathname
# expand _ path(default _ dir = & # 39; . & # 39;) -> Pathname (18335.0) -
Pathname.new(File.expand_path(self.to_s, *args)) と同じです。
...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... -
Kernel
. # require _ relative(relative _ feature) -> bool (12306.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... -
File
. absolute _ path(file _ name , dir _ string=nil) -> String (9312.0) -
file_name を絶対パスに変換した文字列を返します。
...file_name を絶対パスに変換した文字列を返します。
相対パスの場合はカレントディレクトリを基準とします。
dir_string を渡した場合はそのディレクトリを基準とします。
File.expand_path と異なり、 file_name 先頭が "~" である場....../emlist[例][ruby]{
p Dir.getwd #=> "/home/matz/work/bar"
p ENV["HOME"] #=> "/home/matz"
p File.absolute_path("..") #=> "/home/matz/work"
p File.absolute_path("..", "/tmp") #=> "/"
p File.absolute_path("~") #=> "/home/matz/work/bar/~"
p File.a......bsolute_path("~foo") #=> "/home/matz/work/bar/~foo"
//}
@see File.expand_path... -
DOSISH 対応 (9084.0)
-
DOSISH 対応 ruby version 1.7 では、DOSISH対応(DOS/Windows のパス名の扱いに対する変 更)が含まれています。(現在の)変更点を以下に示します。
...DOSISH 対応
ruby version 1.7 では、DOSISH対応(DOS/Windows のパス名の扱いに対する変
更)が含まれています。(現在の)変更点を以下に示します。
なお、これらの変更は platform/mswin32 版、platform/mingw32
版の Ruby にのみあてはまります。......ては現在もruby-listなどで議論が継続されています。
現時点では、Fileの各メソッドに対する\対応, マルチバイトパス名対応, UNC 対応が実装されています。13817, 14097
以下、各メソッドの挙動について...
: File.dirname
パスセパ......y 1.6.4 (2001-06-04) [i586-mswin32]
"C:\\foo\\bar"
=> ruby 1.7.1 (2001-08-16) [i586-mswin32]
"bar"
: File.split
File.dirname と File.basename が変更されているので、File.split もそれに準じた
結果を返します。
: File.expand_path
ドライブレタ... -
変数と定数 (6030.0)
-
変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio
...変数と定数
* local
* instance
* class
* class_var_scope
* global
* pseudo
* const
* prio
Ruby の変数と定数の種別は変数名の最初の一文字によって、
ローカル変数、
インスタンス変数、
クラス変数、
グローバル変数、
定数
のい......数の一部には
「`$'+1文字の記号」という変数があります(builtinを参照)。変数名
の長さにはメモリのサイズ以外の制限はありません。
===[a:local] ローカル変数
//emlist[例][ruby]{
foobar
//}
小文字または`_'で始まる識別子はローカ......: false
FalseClassクラスの唯一のインスタンス。nilとfalseは偽を表します。
Object#frozen? は true を返します。
: __FILE__
現在のソースファイル名
フルパスとは限らないため、フルパスが必要な場合は
File.expand_path(__FILE__)... -
Dir
. home -> String | nil (3218.0) -
現在のユーザまたは指定されたユーザのホームディレクトリを返します。
...れたユーザのホームディレクトリを返します。
Dir.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。
//emlist[例][ruby]{
Dir.home # => "/home/vagrant"
Dir.home("root") # => "/root"
//}
@see File.expand_path......されたユーザのホームディレクトリを返します。
Dir.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。
//emlist[例][ruby]{
Dir.home # => "/home/vagrant"
Dir.home("root") # => "/root"
//}
@see File.expand_path... -
Dir
. home(user) -> String | nil (3218.0) -
現在のユーザまたは指定されたユーザのホームディレクトリを返します。
...れたユーザのホームディレクトリを返します。
Dir.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。
//emlist[例][ruby]{
Dir.home # => "/home/vagrant"
Dir.home("root") # => "/root"
//}
@see File.expand_path......されたユーザのホームディレクトリを返します。
Dir.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。
//emlist[例][ruby]{
Dir.home # => "/home/vagrant"
Dir.home("root") # => "/root"
//}
@see File.expand_path...