種類
- モジュール関数 (16)
- インスタンスメソッド (10)
- 変数 (2)
検索結果
先頭5件
- Kernel
# convertible _ int(type , headers = nil , opts = nil) - Kernel
# convertible _ int(type , headers = nil , opts = nil) { . . . } - Kernel
# timeout(sec , exception _ class = nil) {|i| . . . . } -> object - Kernel
# arg _ config(config , default) { . . . } -> object | String | true | nil - Kernel
# with _ werror(opt , opts = nil) {|opt , opts| . . . } -> object
-
Kernel
# convertible _ int(type , headers = nil , opts = nil) (664.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are p... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) { . . . } (664.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are p... -
Kernel
# timeout(sec , exception _ class = nil) {|i| . . . . } -> object (631.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
ブロックを sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。
また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
=== 注意
timeout に... -
Kernel
# arg _ config(config , default) { . . . } -> object | String | true | nil (628.0) -
configure オプション --config の値を返します。
configure オプション --config の値を返します。
@param config オプションを文字列で指定します。
@param default 引数 config で指定したオプションのデフォルト値を指定します。
@return オプションが指定されてた場合は true を、指定されなかった場合は
nil を返します。
引数 default、あるいはブロックを指定すると、オプションが指定さ
れていない場合に引数 default の値かブロックの評価結果を返します
(両方指定した場合はブロックが優先されます)... -
Kernel
# with _ werror(opt , opts = nil) {|opt , opts| . . . } -> object (616.0) -
@todo 内部用?
@todo 内部用?
???
@param opt ????
@param opts ????
@return ブロックを評価した結果を返します。 -
Kernel
# with _ werror(opt , opts = nil) {|opt| . . . } -> object (616.0) -
@todo 内部用?
@todo 内部用?
???
@param opt ????
@param opts ????
@return ブロックを評価した結果を返します。 -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) {|ouri| . . . } -> object (613.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...ock) のように name の open メソッドが呼ばれます。
これ以外の場合は、name はファイル名として扱われ、従来の
Kernel.#open(name, *rest) が呼ばれます。
ブロックを与えた場合は上の場合と同様、name が http:// や ftp:// で
始まって......uby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or......ram mode モードを文字列で与えます。Kernel.#open と同じです。
@param perm open(2) の第 3 引数のように、ファイルを生成する場合のファイルのパーミッションを
整数で指定します。Kernel.#open と同じです
@param options ハッシ... -
Kernel
. # loop { . . . } -> object | nil (610.0) -
(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。
...by]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
end
//}
与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して Enumerator が最後に返した値を返します。
ループを終了させる場合、通常は bre... -
Kernel
# j(*objects) -> nil (607.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 (607.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
. # Float(arg , exception: true) -> Float | nil (415.0) -
引数を浮動小数点数(Float)に変換した結果を返します。
引数を浮動小数点数(Float)に変換した結果を返します。
引数が数値の場合は素直に変換し、文字列の場合
は整数や浮動小数点数と見なせるもののみ変換します。
メソッド Float は文字列に対し String#to_f よりも厳密な変換を行います。
@param arg 変換対象のオブジェクトです。
@param exception false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。
@raise ArgumentError 整数や浮動小数点数と見なせない文字列を引数に指定した場合に発生します。
@raise... -
Kernel
. # Integer(arg , base = 0 , exception: true) -> Integer | nil (415.0) -
引数を整数 (Fixnum,Bignum) に変換した結果を返します。
引数を整数
(Fixnum,Bignum)
に変換した結果を返します。
引数が数値の場合は直接変換し(小数点以下切り落とし)、
文字列の場合は、進数を表す接頭辞を含む整数表現とみなせる文字列のみ
変換します。
数値と文字列以外のオブジェクトに対しては arg.to_int, arg.to_i を
この順に使用して変換します。
@param arg 変換対象のオブジェクトです。
@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略するか0を指定した場合はプリフィクスか
ら基数を... -
Kernel
. # gets(rs = $ / ) -> String | nil (415.0) -
ARGFから一行読み込んで、それを返します。 行の区切りは引数 rs で指定した文字列になります。
...mmon
//}
//emlist[c.txt][ruby]{
ARGF
# スクリプトに指定した引数 (Object::ARGV を参照) をファイル名と
# みなして、それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。
//}
@see $/,ARGF,Kernel.#readlines,Kernel.#readline... -
Kernel
$ $ _ -> String | nil (391.0) -
最後に Kernel.#gets または Kernel.#readline で読み込んだ文字列です。 EOF に達した場合には、 nil になります。 (覚え方: Perlと同じ)
...最後に Kernel.#gets または Kernel.#readline で読み込んだ文字列です。
EOF に達した場合には、 nil になります。
(覚え方: Perlと同じ)
Kernel.#print のような Perl 由来の幾つかのメソッドは、引数を省略すると代わりに $_ を利用します......。
この変数はローカルスコープかつスレッドローカルです。
Ruby起動時の初期値は nil です。
@see Kernel.#print, Kernel.#gets, Kernel.#readline, Object::ARGF
=== 例
example.txt:
foo
bar
baz
このとき、コマンド ruby -e 'print while gets' example.txt... -
Kernel
. # eval(expr) -> object (364.0) -
文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。
...val('a = RUBY_RELEASE_DATE')
p a #=> "2007-03-13"
eval('def fuga;p 777 end')
fuga #=> 777
eval('raise RuntimeError', binding, 'XXX.rb', 4)
#=> XXX.rb:4: RuntimeError (RuntimeError)
# from ..:9
//}
@see Kernel.#binding,Module#module_eval,BasicObject#instance_eval,Object#method,Object#send... -
Kernel
. # eval(expr , bind , fname = "(eval)" , lineno = 1) -> object (364.0) -
文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。
...val('a = RUBY_RELEASE_DATE')
p a #=> "2007-03-13"
eval('def fuga;p 777 end')
fuga #=> 777
eval('raise RuntimeError', binding, 'XXX.rb', 4)
#=> XXX.rb:4: RuntimeError (RuntimeError)
# from ..:9
//}
@see Kernel.#binding,Module#module_eval,BasicObject#instance_eval,Object#method,Object#send... -
Kernel
. # Rational(x , y = 1 , exception: true) -> Rational | nil (361.0) -
引数を有理数(Rational)に変換した結果を返します。
...スコアで繋いだ形式
"1.2/3" のように、分子を実数にする事も可能ですが、分母には指定できませ
ん。また、Kernel.#Integer とは違い "0x10" のような進数を表す接頭
辞を含めた指定は行えません。
//emlist[例][ruby]{
Rational("1/3")... -
Kernel
$ $ -i -> String | nil (343.0) -
in-place 置換モードで用いられます。
in-place 置換モードで用いられます。
コマンドラインオプション -i を指定したとき、空文字列になります。
-i オプションに拡張子を渡した場合にはその拡張子が文字列として格納されます。
-i オプションが指定されていない時の値は nil です。
スクリプト内で $-i に代入することもでき、
その場合は Object::ARGV の次の
ファイルを読み込み始めるタイミングで in-place 置換を開始します。
この変数はグローバルスコープです。
@see spec/rubycmd -
Kernel
. # throw(tag , value = nil) -> () (343.0) -
Kernel.#catchとの組み合わせで大域脱出を行います。 throw は同じ tag を指定した catch のブロックの終わりまでジャンプします。
...
Kernel.#catchとの組み合わせで大域脱出を行います。 throw
は同じ tag を指定した catch のブロックの終わりまでジャンプします。
throw は探索時に呼び出しスタックをさかのぼるので、
ジャンプ先は同じメソッド内にあるとは限......いる catch が存在しない場合に発生します。
//emlist[例][ruby]{
def foo
throw :exit, 25
end
ret = catch(:exit) do
begin
foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=> ensure
# 25
//}
@see Kernel.#catch... -
Kernel
# timeout(sec) {|i| . . . . } -> object (331.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
ブロックを sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。
また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。
@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
=== 注意
timeout に... -
Kernel
# xmp(exps , bind = nil) -> XMP (325.0) -
引数 exps で指定されたRuby のソースコードとその実行結果を、標準出力に行 ごとに交互に表示します。
...定します。
@param bind Binding オブジェクトを指定します。省略した場合は、最
後に実行した XMP#puts、Kernel#xmp の
Binding を使用します。まだ何も実行していない場合は
Object::TOPLEVEL_BINDING を使用します... -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO | Tempfile | IO (313.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...ock) のように name の open メソッドが呼ばれます。
これ以外の場合は、name はファイル名として扱われ、従来の
Kernel.#open(name, *rest) が呼ばれます。
ブロックを与えた場合は上の場合と同様、name が http:// や ftp:// で
始まって......uby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or......ram mode モードを文字列で与えます。Kernel.#open と同じです。
@param perm open(2) の第 3 引数のように、ファイルを生成する場合のファイルのパーミッションを
整数で指定します。Kernel.#open と同じです
@param options ハッシ... -
Kernel
. # lambda { . . . } -> Proc (76.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}
===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い
Kernel.#lambda と Proc.new はどちらも Proc クラスのインスタンス(手続きオブジェクト)を生成しますが、
生成された手......。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。
Kernel.#proc は Proc.new と同じになります。
引数に & を付けることで手続きオブジェクト化したブロックは、Proc.new で... -
Kernel
. # proc -> Proc (76.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}
===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い
Kernel.#lambda と Proc.new はどちらも Proc クラスのインスタンス(手続きオブジェクト)を生成しますが、
生成された手......。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。
Kernel.#proc は Proc.new と同じになります。
引数に & を付けることで手続きオブジェクト化したブロックは、Proc.new で... -
Kernel
. # proc { . . . } -> Proc (76.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}
===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い
Kernel.#lambda と Proc.new はどちらも Proc クラスのインスタンス(手続きオブジェクト)を生成しますが、
生成された手......。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。
Kernel.#proc は Proc.new と同じになります。
引数に & を付けることで手続きオブジェクト化したブロックは、Proc.new で... -
Kernel
. # readline(rs = $ / ) -> String (76.0) -
ARGFから一行読み込んで、それを返します。 行の区切りは引数 rs で指定した文字列になります。
...t ---
hello
it
common
# --- c.txt ---
ARGF
# スクリプトに指定した引数 (Object::ARGV を参照) をファイル名と
# みなして、それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。
//}
@see $/,ARGF,Kernel.#readlines,Kernel.#gets... -
Kernel
. # Array(arg) -> Array (58.0) -
引数を配列(Array)に変換した結果を返します。
引数を配列(Array)に変換した結果を返します。
arg.to_ary と arg.to_a をこの順に呼び出して、返ってきた配列を変換結果とします。
arg に to_ary, to_a のいずれのメソッドも定義されていない場合は
一要素の配列 [arg] を返します。
@param arg 変換対象のオブジェクトです。
@raise TypeError to_ary, to_a の返り値が配列でなければ発生します
//emlist[例][ruby]{
p Array({:it => 3}) #=> [[:it, 3]]
p Array(nil) #=> []
p Array("... -
Kernel
. # loop -> Enumerator (10.0) -
(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。
...by]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
end
//}
与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して Enumerator が最後に返した値を返します。
ループを終了させる場合、通常は bre...