別のキーワード
種類
- インスタンスメソッド (341)
- 特異メソッド (187)
- モジュール関数 (73)
クラス
- Array (99)
-
Encoding
:: Converter (11) - IO (154)
- Object (22)
- StopIteration (11)
- String (132)
モジュール
- Enumerable (66)
-
GC
:: Profiler (33) - Kernel (62)
- ObjectSpace (11)
キーワード
- [] (66)
-
_ dump (11) - catch (22)
-
count
_ objects (11) - fetch (33)
- inject (33)
- loop (18)
-
marshal
_ dump (11) - permutation (22)
- popen (154)
-
primitive
_ errinfo (11) -
raw
_ data (11) - reduce (33)
-
repeated
_ combination (22) -
repeated
_ permutation (22) - report (11)
- slice (66)
- test (22)
検索結果
先頭5件
-
StopIteration
# result -> object (21127.0) -
この例外オブジェクトを発生させる原因となったメソッド等の返り値を返します。
...ect = Object.new
def object.each
yield :yield1
yield :yield2
:each_returned
end
enumerator = object.to_enum
p enumerator.next #=> :yield1
p enumerator.next #=> :yield2
begin
enumerator.next
rescue StopIteration => error
p error.result #=> :each_returned
end... -
GC
:: Profiler . result -> String (21109.0) -
GC のプロファイル情報をフォーマットし、文字列として返します。
...生ごとに集計します。
以下は、5 回 GC が発生した場合の実行例です。
$ ruby -e "GC::Profiler.enable; a = Array.new(100000){ 'aa' }; puts GC::Profiler.result"
GC 5 invokes.
Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object......Time
Ruby が起動してから GC が起動するまでに経過した時間
: Use Size
ヒープ内での使用サイズ
: Total Size
ヒープ全体のサイズ
: Total Object
ヒープ内に存在するオブジェクトの個数
: GC Time
GC の処理時間
@see GC::Profiler.report... -
Array
# repeated _ permutation(n) -> Enumerator (12221.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙......a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one perm......ロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}
@see Array#repeated_combination, Array#permutation... -
Array
# repeated _ permutation(n) { |p| . . . } -> self (12221.0) -
サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。
...オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙......a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one perm......ロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}
@see Array#repeated_combination, Array#permutation... -
Encoding
:: Converter # primitive _ errinfo -> Array (6162.0) -
直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。
...直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。
@return [result, enc1, enc2, error_bytes, readagain_bytes] という五要素の配列
result は直前の primitive_convert の戻り値です。
それ以外の四要素は......:invalid_byte_sequence か :incomplete_input か :undefined_conversion だった場合に意味を持ちます。
enc1 はエラーの発生した原始変換の変換元のエンコーディング、enc2 は変換先のエンコーディングです。
error_bytes はエラーの発生原因とな......
primitive_errinfo はもっぱら Encoding::Converter#primitive_convert と組み合わせて使います。Encoding::Converter#convert を用いている場合にも取得することはできますが、有用な使い方は難しいでしょう。
//emlist[][ruby]{
# \xff is invalid as EUC-JP.... -
Object
# _ dump(limit) -> String (6138.0) -
Marshal.#dump において出力するオブジェクトがメソッド _dump を定義している場合には、そのメソッドの結果が書き出されます。
...Marshal.#dump において出力するオブジェクトがメソッド _dump
を定義している場合には、そのメソッドの結果が書き出されます。
バージョン1.8.0以降ではObject#marshal_dump, Object#marshal_loadの使用
が推奨されます。 Marshal.dump するオ......mp と marshal_dump の両方の
メソッドを持つ場合は marshal_dump が優先されます。
メソッド _dump は引数として再帰を制限するレベル limit を受
け取り、オブジェクトを文字列化したものを返します。
インスタンスがメソッド _dump......あります。
@param limit 再帰の制限レベルを表す整数です。
@return オブジェクトを文字列化したものを返すように定義すべきです。
//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end
def _dump(limit)
Marshal.dump(@foo, limit)
en... -
Object
# marshal _ dump -> object (6138.0) -
Marshal.#dump を制御するメソッドです。
...Marshal.#dump を制御するメソッドです。
Marshal.dump(some) において、出力するオブジェクト some がメソッド marshal_dump を
持つ場合には、その返り値がダンプされたものが Marshal.dump(some) の返り値となります。
marshal_dump/marshal_load......dump/_load ではなく
marshal_dump/marshal_load を使うべきです。
@return 任意のオブジェクトで marshal_load の引数に利用できます。
//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end
def marshal_dump
@foo
end
def marshal_load(obj)
p ob......end
foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf3b0 @foo=["foo", "bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bU:\bFoo[\a\"\bfoo\"\bbar"
result = Marshal.load(dms) #=> ["foo", "bar"] # marshal_load の引数
p result #=> #<Foo:0xb... -
IO
. popen([env = {} , [cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) -> IO (6134.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
...イプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。......す。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
# => "foo\n"
opt でプロセス起動のためのオプションや、パイプ IO オブジェクトの属性(......めのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です。
つまり、 :external_encoding や :unsetenv_others が指定できます。
オプションの詳しい意味は Kernel.#spawn や IO.new を参照してくだ... -
IO
. popen([env = {} , [cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) {|f| . . . } -> object (6134.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
...イプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。......す。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
# => "foo\n"
opt でプロセス起動のためのオプションや、パイプ IO オブジェクトの属性(......めのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です。
つまり、 :external_encoding や :unsetenv_others が指定できます。
オプションの詳しい意味は Kernel.#spawn や IO.new を参照してくだ... -
IO
. popen([env = {} , cmdname , *args , execopt={}] , mode = "r" , opt={}) -> IO (6134.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
...イプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。......す。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
# => "foo\n"
opt でプロセス起動のためのオプションや、パイプ IO オブジェクトの属性(......めのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です。
つまり、 :external_encoding や :unsetenv_others が指定できます。
オプションの詳しい意味は Kernel.#spawn や IO.new を参照してくだ...