33件ヒット
[1-33件を表示]
(0.398秒)
検索結果
-
Object
# pretty _ print _ cycle(pp) -> () (24307.0) -
プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。
...etty_print の代わりに呼ばれるメソッドです。
あるクラスの pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。
@param pp PP オブジェクトです。
//emlist[][ruby]{
class Array
def pretty_print_cycle(q)......q.text(empty? ? '[]' : '[...]')
end
end
//}
@see Object#pretty_print... -
PP
. sharing _ detection -> bool (6216.0) -
共有検出フラグを表すアクセサです。 デフォルトは false です。true である場合、 PP.pp は一度出力したオブジェクトを再び出力する時 Object#pretty_print_cycle を使います。
...び出力する時
Object#pretty_print_cycle を使います。
@param boolean 共有検出フラグを true か false で指定します。
//emlist[][ruby]{
require 'pp'
b = [1, 2, 3]
a = [b, b]
pp a #=> [[1, 2, 3], [1, 2, 3]]
PP.sharing_detection = true
pp a......を再び出力する時
Object#pretty_print_cycle を使います。
@param boolean 共有検出フラグを true か false で指定します。
//emlist[][ruby]{
b = [1, 2, 3]
a = [b, b]
pp a #=> [[1, 2, 3], [1, 2, 3]]
PP.sharing_detection = true
pp a... -
Object
# pretty _ print(pp) -> () (6206.0) -
PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。
...します。
そのとき pretty_print メソッドは指定された pp に対して表示したい自身の内容を追加して
いかなければいけません。いくつかの組み込みクラスについて、
pp ライブラリはあらかじめ pretty_print メソッドを定義してい......ブジェクトです。
//emlist[][ruby]{
require 'pp'
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}
@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#breakable......@param pp PP オブジェクトです。
//emlist[][ruby]{
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}
@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#breakable...