クラス
- Array (525)
- Complex (11)
- Data (4)
- Enumerator (11)
- File (16)
- Float (19)
- Integer (36)
- Module (66)
- Object (22)
- Range (194)
- Rational (55)
- Regexp (11)
- String (11)
- SystemCallError (33)
- UnboundMethod (11)
モジュール
- Enumerable (132)
- Kernel (161)
- Marshal (44)
- Math (99)
- ObjectSpace (11)
キーワード
-
$ @ (11) -
$ SAFE (7) -
$ ~ (11) - & (11)
- * (22)
- ** (11)
- + (11)
- - (11)
- < (11)
- <= (11)
- =~ (22)
- > (11)
- >= (11)
- ArgumentError (11)
- Array (11)
- Float (11)
- Hash (11)
- Integer (22)
-
MAJOR
_ VERSION (11) -
MINOR
_ VERSION (11) - String (11)
- [] (33)
- []= (22)
-
absolute
_ path? (5) - at (11)
- begin (11)
- bind (11)
- bsearch (44)
- ceil (11)
- coerce (11)
- combination (22)
-
count
_ objects (11) - cycle (22)
- define (4)
-
define
_ method (44) -
delete
_ at (11) - dig (9)
- dup (3)
- each (22)
- end (11)
- erf (11)
- erfc (11)
- exp (11)
- fail (33)
- feed (11)
- fetch (33)
- first (33)
- flatten (11)
- flatten! (11)
- floor (11)
- freeze (5)
- frexp (11)
- gamma (11)
-
initialize
_ copy (11) - insert (11)
- intersection (5)
- join (22)
- last (33)
- ldexp (11)
- lgamma (11)
- load (11)
- log (22)
- max (86)
- min (86)
- new (33)
- permutation (22)
- pop (11)
- pow (22)
- putc (11)
- raise (33)
-
repeated
_ combination (22) -
repeated
_ permutation (22) - replace (11)
- restore (11)
- rotate (11)
- rotate! (11)
- round (30)
- sample (44)
- shift (11)
-
singleton
_ class (11) - sort (22)
- sum (38)
-
to
_ i (11) - transpose (11)
- truncate (11)
-
try
_ convert (3) - zip (11)
- | (11)
検索結果
先頭5件
-
TypeError (52002.0)
-
メソッドの引数に期待される型ではないオブジェクトや、期待される振る舞いを持たないオブジェクトが渡された時に発生します。
...メソッドの引数に期待される型ではないオブジェクトや、期待される振る舞いを持たないオブジェクトが渡された時に発生します。
@see ArgumentError... -
Kernel
. # Integer(arg , base = 0) -> Integer (17226.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...に対しては arg.to_int, arg.to_i を
この順に使用して変換します。
@param arg 変換対象のオブジェクトです。
@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略するか0を指定......数) です。
@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッド to_int, to_i を持たないオブジェクトを引数に指定したか、to_int, to_i
が整数(Integerのサブクラス)を返さ......@raise TypeError 引数に nil を指定した場合に発生します。
//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(nil) # can't convert nil into Integer (TypeError)
p Integer(Object.new) # cannot convert Object in... -
Kernel
. # Integer(arg , base = 0 , exception: true) -> Integer | nil (17226.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...に対しては arg.to_int, arg.to_i を
この順に使用して変換します。
@param arg 変換対象のオブジェクトです。
@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略するか0を指定......す。
@param exception false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。
@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッド to_......(Integerのサブクラス)を返さなかった場合に発生します。
@raise TypeError 引数に nil を指定した場合に発生します。
//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(nil) # can't convert ni... -
ObjectSpace
. # count _ objects(result _ hash = {}) -> Hash (17108.0) -
オブジェクトを種類ごとにカウントした結果を Hash として返します。
...am result_hash ハッシュを指定します。与えられたハッシュは上書きして返されます。
これを利用すると測定による影響を避けることができます。
@raise TypeError 引数に Hash 以外を与えた場合、発生します。
//emlis......t[例][ruby]{
ObjectSpace.count_objects # => {:TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, ...}
//}... -
Array
# permutation(n = self . length) -> Enumerator (14220.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...成する Enumerator オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に......//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.per......e permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of length 4
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.permutation(2) {|e... -
Array
# intersection(*other _ arrays) -> Array (14208.0) -
自身と引数に渡された配列の共通要素を新しい配列として返します。 要素が重複する場合は、そのうちの1つのみを返します。 要素の順序は自身の順序を維持します。
...ます。
@param other_arrays 自身と共通要素を取りたい配列を指定します。
配列以外のオブジェクトを指定した場合は to_ary
メソッドによる暗黙の型変換を試みます。
@raise TypeError 引数に配列以外の......ersectionはObject#hashとObject#eql?を使って比較を行います。
//emlist[例][ruby]{
[1, 1, 3, 5].intersection([3, 2, 1]) # => [1, 3]
["a", "b", "z"].intersection(["a", "b", "c"], ["b"]) # => ["b"]
["a"].intersection # => ["a"]
//}
@se......e Set#intersection, Array#&... -
Complex
# coerce(other) -> [Complex , Complex] (14208.0) -
other を Complex に変換して [変換後の other, self] の配列を返します。
...other を Complex に変換して [変換後の other, self] の配列を返します。
@raise TypeError 変換できないオブジェクトを指定した場合に発生します。
//emlist[例][ruby]{
Complex(1).coerce(2) # => [(2+0i), (1+0i)]
//}... -
File
. absolute _ path?(file _ name) -> bool (14208.0) -
file_name が絶対パスなら true を、そうでなければ false を返します。
...e_name が絶対パスなら true を、そうでなければ false を返します。
@param file_name ファイル名を表す文字列を指定します。文字列でない場合は、to_path メソッド、to_str メソッドの順で暗黙の型変換が試みられます。
@raise TypeError......//emlist[例][ruby]{
File.absolute_path?("//foo/bar\\baz") # => true
File.absolute_path?("C:foo\\bar") # => false
File.absolute_path?("~") # => false
# プラットフォームが cygwin、mswin、mingw の場合
File.absolute_path?("C:\\foo\\bar") # => true
File.absolute_path?......("/foo/bar\\baz") # => false
# プラットフォームが上記以外の場合
File.absolute_path?("C:\\foo\\bar") # => false
File.absolute_path?("/foo/bar\\baz") # => true
//}... -
Integer
. try _ convert(obj) -> Integer | nil (14208.0) -
obj を Integer に変換しようと試みます。変換には Object#to_int メソッドが使われます。
...Integer に変換しようと試みます。変換には Object#to_int
メソッドが使われます。
Integer ならそのままobjを返します。
そうでなければ obj.to_int の結果を返すか、nil が返されます。
@param obj 変換する任意のオブジェクト
@return......Integer または nil
@raise TypeError to_int が Integer を返さなかった場合に発生します。
//emlist[例][ruby]{
Integer.try_convert(1) # => 1
Integer.try_convert(1.25) # => 1
Integer.try_convert([]) # => nil
//}... -
Marshal
:: MAJOR _ VERSION -> Integer (14208.0) -
Marshal.#dump が出力するデータフォーマットのバージョン番号です。
...ジョンの大きな
マーシャルデータを読み込んだとき例外 TypeError を発生させます。
マイナーバージョンが古いだけのフォーマットは読み込み可能ですが、
$VERBOSE = true のときには警告メッセージが出力されます
マーシャル......されたデータのバージョン番号は以下のようにして取得するこ
とができます。
//emlist[例][ruby]{
obj = Object.new
major, minor = Marshal.dump(obj).unpack("cc")
p [major, minor]
# => [4, 8]
//}... -
Marshal
:: MINOR _ VERSION -> Integer (14208.0) -
Marshal.#dump が出力するデータフォーマットのバージョン番号です。
...ジョンの大きな
マーシャルデータを読み込んだとき例外 TypeError を発生させます。
マイナーバージョンが古いだけのフォーマットは読み込み可能ですが、
$VERBOSE = true のときには警告メッセージが出力されます
マーシャル......されたデータのバージョン番号は以下のようにして取得するこ
とができます。
//emlist[例][ruby]{
obj = Object.new
major, minor = Marshal.dump(obj).unpack("cc")
p [major, minor]
# => [4, 8]
//}... -
Math
. # ldexp(x , exp) -> Float (14208.0) -
実数 x に 2 の exp 乗をかけた数を返します。
...実数 x に 2 の exp 乗をかけた数を返します。
@param x 実数
@param exp 整数。小数点以下切捨て。
@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。
@raise RangeError 引数のどちらかに実数以外の数値を指定し......た場合に発生します。
//emlist[例][ruby]{
fraction, exponent = Math.frexp(1234)
Math.ldexp(fraction, exponent) # => 1234.0
//}...