ライブラリ
- ビルトイン (729)
モジュール
- FileTest (22)
- Kernel (333)
- Math (297)
- ObjectSpace (33)
- Process (44)
キーワード
- Float (11)
- Rational (11)
- acos (11)
- acosh (11)
- asin (11)
- asinh (11)
-
at
_ exit (11) - atan (11)
- atan2 (11)
- atanh (11)
- autoload (11)
- caller (33)
-
caller
_ locations (22) - catch (22)
- cbrt (11)
-
clock
_ gettime (11) - cos (11)
- cosh (11)
-
each
_ object (22) - erf (11)
- erfc (11)
- exit (11)
- exit! (11)
- exp (11)
- fork (22)
- format (11)
- frexp (11)
- gamma (11)
-
garbage
_ collect (11) - gsub (33)
- hypot (11)
- iterator? (11)
- ldexp (11)
- lgamma (11)
- log (22)
- log10 (11)
- log2 (11)
- loop (11)
- printf (22)
- rand (22)
- require (11)
-
require
_ relative (11) - sin (11)
- sinh (11)
- sprintf (11)
- sqrt (11)
- sub (22)
- tan (11)
- tanh (11)
- wait2 (11)
- waitall (11)
- waitpid2 (11)
- warn (3)
-
world
_ readable? (11) -
world
_ writable? (11)
検索結果
先頭5件
-
Math
. # atan(x) -> Float (17201.0) -
x の逆正接関数(arctangent)の値をラジアンで返します。
...rn 返される値の範囲は [-π/2, +π/2] です。
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.atan(0) # => 0.0
//}
@see Math.#atan2, Math.#tan... -
Math
. # atan2(y , x) -> Float (17201.0) -
y / x の逆正接関数(arctangent)の値をラジアンで返します。
...list[例][ruby]{
Math.atan2(1,0) #=> 1.5707963267949
Math.atan2(-1,0) #=> -1.5707963267949
//}
@raise TypeError y, x に数値以外を指定した場合に発生します。
@raise RangeError y, x に実数以外の数値を指定した場合に発生します。
@see Math.#atan, Math.#tan... -
Math
. # atanh(x) -> Float (17201.0) -
x の逆双曲線正接関数(area hyperbolic tangent)の値を返します。
...perbolic tangent)の値を返します。
=== 定義
atanh(x) = log((1+x)/(1-x)) / 2 [-1 < x < 1]
@param x -1 < x < 1 の実数
@return 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した......場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
@see Math.#tanh... -
Kernel
. # require _ relative(relative _ feature) -> bool (14301.0) -
現在のファイルからの相対パスで require します。
...re します。
require File.expand_path(relative_feature, File.dirname(__FILE__))
とほぼ同じです。
Kernel.#eval などで文字列を評価した場合に、そこから
require_relative を呼出すと必ず失敗します。
@param relative_feature ファイル名の文字列です... -
Kernel
. # Float(arg) -> Float (14201.0) -
引数を浮動小数点数(Float)に変換した結果を返します。
...引数を浮動小数点数(Float)に変換した結果を返します。
引数が数値の場合は素直に変換し、文字列の場合
は整数や浮動小数点数と見なせるもののみ変換します。
メソッド Float は文字列に対し String#to_f よりも厳密な変換を......][ruby]{
p Float(4) #=> 4.0
p Float(4_000) #=> 4000.0
p Float(9.88) #=> 9.88
p Float(Time.gm(1986)) #=> 504921600.0
p Float(Object.new) # can't convert Object into Float (TypeError)
p Float(nil) # can't convert nil into Float (TypeError)
p Float("10") #......00.0
p Float("1e-2") #=> 0.01
p Float(".1") #=> 0.1
p Float("0xa") #=> 10.0
p Float("nan") # invalid value for Float(): "nan" (ArgumentError)
p Float("INF") # invalid value for Float(): "INF" (ArgumentError)
p Float("-Inf") # invalid value for Float(): "-Inf... -
Kernel
. # Float(arg , exception: true) -> Float | nil (14201.0) -
引数を浮動小数点数(Float)に変換した結果を返します。
...引数を浮動小数点数(Float)に変換した結果を返します。
引数が数値の場合は素直に変換し、文字列の場合
は整数や浮動小数点数と見なせるもののみ変換します。
メソッド Float は文字列に対し String#to_f よりも厳密な変換を......][ruby]{
p Float(4) #=> 4.0
p Float(4_000) #=> 4000.0
p Float(9.88) #=> 9.88
p Float(Time.gm(1986)) #=> 504921600.0
p Float(Object.new) # can't convert Object into Float (TypeError)
p Float(nil) # can't convert nil into Float (TypeError)
p Float("10") #......00.0
p Float("1e-2") #=> 0.01
p Float(".1") #=> 0.1
p Float("0xa") #=> 10.0
p Float("nan") # invalid value for Float(): "nan" (ArgumentError)
p Float("INF") # invalid value for Float(): "INF" (ArgumentError)
p Float("-Inf") # invalid value for Float(): "-Inf... -
Kernel
. # Rational(x , y = 1) -> Rational (14201.0) -
引数を有理数(Rational)に変換した結果を返します。
...引数を有理数(Rational)に変換した結果を返します。
@param x 変換対象のオブジェクトです。
@param y 変換対象のオブジェクトです。省略した場合は x だけを用いて
Rational オブジェクトを作成します。
@raise ArgumentError......、x/y した Rational オブジェクトを
返します。
//emlist[例][ruby]{
Rational("1/3") # => (1/3)
Rational(1, 3) # => (1/3)
Rational("0.1", "0.3") # => (1/3)
Rational(Complex(1,2), 2) # => ((1/2)+(1/1)*i)
//}
ただし、1.8系とは異なり、Rational オブジ......ェクトは常に既約(それ以上
約分できない状態)である事に注意してください。
//emlist[例][ruby]{
Rational(2, 6) # => (1/3)
Rational(1, 3) * 3 # => (1/1)
//}
引数に文字列を指定する場合、以下のいずれかの形式で指定します。
* "... -
Kernel
. # Rational(x , y = 1 , exception: true) -> Rational | nil (14201.0) -
引数を有理数(Rational)に変換した結果を返します。
...引数を有理数(Rational)に変換した結果を返します。
@param x 変換対象のオブジェクトです。
@param y 変換対象のオブジェクトです。省略した場合は x だけを用いて
Rational オブジェクトを作成します。
@param exception false......、x/y した Rational オブジェクトを
返します。
//emlist[例][ruby]{
Rational("1/3") # => (1/3)
Rational(1, 3) # => (1/3)
Rational("0.1", "0.3") # => (1/3)
Rational(Complex(1,2), 2) # => ((1/2)+(1/1)*i)
//}
ただし、1.8系とは異なり、Rational オブジ......ェクトは常に既約(それ以上
約分できない状態)である事に注意してください。
//emlist[例][ruby]{
Rational(2, 6) # => (1/3)
Rational(1, 3) * 3 # => (1/1)
//}
引数に文字列を指定する場合、以下のいずれかの形式で指定します。
* "... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (14201.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......y]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1, nil)
# => ["......(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (14201.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......y]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1, nil)
# => ["......(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # format(format , *arg) -> String (14201.0) -
format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。
...format 文字列を C 言語の sprintf と同じように解釈し、
引数をフォーマットした文字列を返します。
@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime
=== sprintf......だし、Float::INFINITY、Float::NAN はそれぞれ 'Inf'、'NaN' になります。詳しくは 40650 を参照してください。
//emlist[][ruby]{
p sprintf("%a", -0.0) # => "-0x0p+0"
p sprintf("%a", 729.0/10) # => "0x1.239999999999ap+6"
p sprintf("%a", Float::INFINITY) # =... -
Kernel
. # at _ exit { . . . } -> Proc (14156.0) -
与えられたブロックをインタプリタ終了時に実行します。
...クをインタプリタ終了時に実行します。
at_exitがメソッドである点を除けば、END ブロックによる終了
処理の登録と同等です。登録した処理を取り消すことはできません。
spec/terminateも参照してください。
@return 登録した処......Proc オブジェクトで返します。
//emlist[例][ruby]{
3.times do |i|
at_exit{puts "at_exit#{i}"}
end
END{puts "END"}
at_exit{puts "at_exit"}
puts "main_end"
#=> main_end
# at_exit
# END
# at_exit2
# at_exit1
# at_exit0
//}
@see d:spec/control#END,Kernel.#exit!,Kernel.#fork...