別のキーワード
種類
- 変数 (12)
- モジュール関数 (6)
- インスタンスメソッド (6)
ライブラリ
- English (9)
- ビルトイン (7)
- bigdecimal (2)
- json (3)
- mkmf (1)
- rubygems (1)
-
rubygems
/ custom _ require (1)
キーワード
-
$ -I (1) -
$ : (1) -
$ ARGV (1) -
$ CHILD _ STATUS (1) -
$ DEFAULT _ INPUT (1) -
$ INPUT _ LINE _ NUMBER (1) -
$ LAST _ MATCH _ INFO (1) -
$ LAST _ PAREN _ MATCH (1) -
$ LOAD _ PATH (1) -
$ NR (1) -
$ ORS (1) -
$ OUTPUT _ RECORD _ SEPARATOR (1) - BigDecimal (2)
- JSON (1)
- autoload (1)
-
create
_ makefile (1) - gem (1)
- j (1)
- jj (1)
- load (1)
-
require
_ relative (1)
検索結果
先頭5件
-
Kernel
. # require(feature) -> bool (72781.0) -
Ruby ライブラリ feature をロードします。拡張子補完を行い、 同じファイルの複数回ロードはしません。
...(/prime/).size # => 0
require "prime" # => true
$LOADED_FEATURES.grep(/prime/).size # => 1
require "prime" # => false
begin
require "invalid"
rescue LoadError => e
e.message # => "cannot load such file -- invalid"
end
//}
@see Kernel.#load,Kernel.#autoload,Kernel.#require_relative... -
Kernel
# require(path) -> bool (72739.0) -
RubyGems を require すると、Kernel#require が Gem を 要求されたときにロードするように置き換えます。
...RubyGems を require すると、Kernel#require が Gem を
要求されたときにロードするように置き換えます。
再定義された Kernel#require を呼び出すと以下の事を行います。
Ruby のロードパスに存在するライブラリを指定した場合はその... -
Kernel
$ $ INPUT _ LINE _ NUMBER -> Integer (36958.0) -
$. の別名
$. の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
require "English"
File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb
ruby sample.rb a.txt
#=> 5 -
Kernel
. # require _ relative(relative _ feature) -> bool (36763.0) -
現在のファイルからの相対パスで require します。
...じです。
Kernel.#eval などで文字列を評価した場合に、そこから
require_relative を呼出すと必ず失敗します。
@param relative_feature ファイル名の文字列です。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require
=== r......ラリのローカル変数を
ロード元のスクリプトから直接取得することはできません。
このスコープの扱い方はKernel.#loadでも同様です。
//emlist[例][ruby]{
# ---------- some.rb -----------
$a = 1
@a = 1
A = 1
a = 1
# ---------- end some.rb -------
requi... -
Kernel
$ $ -I -> [String] (18913.0) -
Rubyライブラリをロードするときの検索パスです。
...Rubyライブラリをロードするときの検索パスです。
Kernel.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。
起動時にはコマンドラインオプション -I で指定したディレクトリ、... -
Kernel
# create _ makefile(target , srcprefix = nil) -> true (18676.0) -
@todo
...@todo
Kernel#have_library などの各種検査の結果を元に、拡張ライブラリを
ビルドするための Makefile を生成します。
extconf.rb は普通このメソッドの呼び出しで終ります。
@param target ターゲットとなる拡張ライブラリの名前を指......create_makefile('foo') {|conf|
[
*conf,
"MACRO_YOU_NEED = something",
]
}
ソースディレクトリに depend ファイルが存在する場合、その内容が
Kernel#depend_rules メソッドで整形されて、生成される Makefile に加えられます。... -
Kernel
$ $ CHILD _ STATUS -> Process :: Status | nil (18658.0) -
$? の別名
$? の別名
require "English"
out = `wget https://www.ruby-lang.org/en/about/license.txt -O - 2>/dev/null`
if $CHILD_STATUS.to_i == 0
print "wget success\n"
out.split(/\n/).each { |line|
printf "%s\n", line
}
else
print "wget failed\n"
end -
Kernel
. # BigDecimal(s , exception: true) -> BigDecimal | nil (18640.0) -
引数で指定した値を表す BigDecimal オブジェクトを生成します。
引数で指定した値を表す BigDecimal オブジェクトを生成します。
@param s 数値を表現する初期値を文字列、Integer、
Float、Rational、BigDecimal オブジェクトのい
ずれかで指定します。
文字列中のスペースは無視されます。また、判断できない文字が出現
した時点で文字列は終了したものとみなされます。
@param n 必要な有効桁数(self の最大有効桁数)を整数で指定します。 n が
0 または省略されたときは、n の値は s の有効桁数とみなされます。... -
Kernel
. # BigDecimal(s , n , exception: true) -> BigDecimal | nil (18640.0) -
引数で指定した値を表す BigDecimal オブジェクトを生成します。
引数で指定した値を表す BigDecimal オブジェクトを生成します。
@param s 数値を表現する初期値を文字列、Integer、
Float、Rational、BigDecimal オブジェクトのい
ずれかで指定します。
文字列中のスペースは無視されます。また、判断できない文字が出現
した時点で文字列は終了したものとみなされます。
@param n 必要な有効桁数(self の最大有効桁数)を整数で指定します。 n が
0 または省略されたときは、n の値は s の有効桁数とみなされます。... -
Kernel
$ $ LAST _ MATCH _ INFO -> MatchData | nil (18376.0) -
$~ の別名
$~ の別名
require "English"
str = "<a href=https://www.ruby-lang.org/en/about/license.txt>license</a>"
if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=https://www.ruby-lang.org/en/about/license.txt>"
p $LAST_MATCH_INFO[1] #=> "https://www.ruby-lang.org/en/about/license.t... -
Kernel
$ $ NR -> Integer (18358.0) -
$. の別名
$. の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
require "English"
File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb
ruby sample.rb a.txt
#=> 5 -
Kernel
$ $ DEFAULT _ INPUT -> IO (18340.0) -
$< の別名
$< の別名
require "English"
while line = $DEFAULT_INPUT.gets
p line
end
# end of sample.rb
ruby sample.rb < /etc/passwd
# => "hoge:x:500:501::/home/hoge:/bin/bash\n"
... -
Kernel
$ $ : -> [String] (9913.0) -
Rubyライブラリをロードするときの検索パスです。
...Rubyライブラリをロードするときの検索パスです。
Kernel.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。
起動時にはコマンドラインオプション -I で指定したディレクトリ、... -
Kernel
$ $ LOAD _ PATH -> [String] (9913.0) -
Rubyライブラリをロードするときの検索パスです。
...Rubyライブラリをロードするときの検索パスです。
Kernel.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。
起動時にはコマンドラインオプション -I で指定したディレクトリ、... -
Kernel
# gem(gem _ name , *version _ requirements) -> bool (724.0) -
$LOAD_PATH に Ruby Gem を追加します。
$LOAD_PATH に Ruby Gem を追加します。
指定された Gem をロードする前にその Gem が必要とする Gem をロードします。
バージョン情報を省略した場合は、最も高いバージョンの Gem をロードします。
指定された Gem やその Gem が必要とする Gem が見つからなかった場合は
Gem::LoadError が発生します。
バージョンの指定方法に関しては Gem::Version を参照してください。
rubygems ライブラリがライブラリバージョンの衝突を検出しない限り、
gem メソッドは全ての require メソッドよりも前に実行されます。
... -
Kernel
. # load(file , priv = false) -> true (460.0) -
Ruby プログラム file をロードして実行します。再ロード可能です。
...。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require
=== require と load の違い
Kernel.#require は同じファイルは一度だけしかロードしませんが、
Kernel.#load は無条件にロードします。
また、require は拡張子.rb や... -
Kernel
. # autoload(const _ name , feature) -> nil (406.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...定数 const_name を最初に参照した時に feature を
Kernel.#require するように設定します。
const_name には、 "::" 演算子を含めることはできません。
ネストした定数を指定する方法は Module#autoload を参照してください。
const_name が aut......対象を指定します。
@raise LoadError featureのロードに失敗すると発生します。
//emlist[][ruby]{
# ------- /tmp/foo.rb ---------
class Bar
end
# ----- end of /tmp/foo.rb ----
autoload :Bar, '/tmp/foo'
p Bar #=> Bar
//}
@see Kernel.#autoload?,Module#autoload,Kernel.#require... -
Kernel
# JSON(object , options = {}) -> object (388.0) -
第一引数に与えられたオブジェクトの種類によって Ruby のオブジェクトか JSON 形式の文字列を返します。
第一引数に与えられたオブジェクトの種類によって Ruby のオブジェクトか JSON 形式の文字列を返します。
第一引数に文字列のようなオブジェクトを指定した場合は、それを JSON.#parse を用いてパースした結果を返します。
そうでないオブジェクトを指定した場合は、それを JSON.#generate を用いて変換した結果を返します。
@param object 任意のオブジェクトを指定します。
@param options JSON.#parse, JSON.#generate に渡すオプションを指定します。
//emlist[例][ruby]{
require "json... -
Kernel
# j(*objects) -> nil (340.0) -
与えられたオブジェクトを JSON 形式の文字列で標準出力に一行で出力します。
...トを JSON 形式の文字列で標準出力に一行で出力します。
@param objects JSON 形式で出力したいオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
j([1,2,{"name" => "tanaka","age" => 19}])
# => [1,2,{"name":"tanaka","age":19}]
//}
@see Kernel.#p... -
Kernel
# jj(*objects) -> nil (340.0) -
与えられたオブジェクトを JSON 形式の文字列で標準出力に人間に読みやすく整形して出力します。
...します。
@param objects JSON 形式で出力したいオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
jj([1,2,{"name" => "tanaka","age" => 19}])
# => [
# 1,
# 2,
# {
# "name": "tanaka",
# "age": 19
# }
# ]
//}
@see Kernel.#pp... -
Kernel
$ $ ARGV -> [String] (340.0) -
$* の別名
$* の別名
require "English"
p $ARGV
# end of sample.rb
ruby sample.rb 31 /home/hoge/fuga.txt
#=> ["31", "/home/hoge/fuga.txt"] -
Kernel
$ $ LAST _ PAREN _ MATCH -> String | nil (340.0) -
$+ の別名
$+ の別名
require "English"
r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")
while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikkou</td>... -
Kernel
$ $ ORS -> String | nil (340.0) -
$\ の別名
$\ の別名
require "English"
print "hoge\nhuga\n"
$OUTPUT_RECORD_SEPARATOR = "\n"
print "fuge"
print "ugo"
# end of sample.rb
ruby sample.rb
hoge
huga
fuge
ugo -
Kernel
$ $ OUTPUT _ RECORD _ SEPARATOR -> String | nil (340.0) -
$\ の別名
$\ の別名
require "English"
print "hoge\nhuga\n"
$OUTPUT_RECORD_SEPARATOR = "\n"
print "fuge"
print "ugo"
# end of sample.rb
ruby sample.rb
hoge
huga
fuge
ugo