るりまサーチ

最速Rubyリファレンスマニュアル検索!
33件ヒット [1-33件を表示] (0.328秒)
トップページ > クエリ:-[x] > クエリ:TEXT[x] > クエリ:pretty_print_cycle[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

キーワード

検索結果

Object#pretty_print_cycle(pp) -> () (18213.0)

プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。

...の pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。

@param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
def pretty_print_cycle(q)
q.text(empty? ? '[]' : '[...]')
end
end
//}

@see Object#pretty_print...

pp (174.0)

オブジェクトなどを見やすく出力するためのライブラリです。

...etty-print されてない出力:
#<PP:0x81a0d10 @stack=[], @genspace=#<Proc:0x81a0cc0>, @nest=[0], @newline="\n",
@buf=#<PrettyPrint::Group:0x81a0c98 @group=0, @tail=0, @buf=[#<PrettyPrint::Gro
up:0x81a0ba8 @group=1, @tail=0, @buf=[#<PrettyPrint::Text:0x81a0b30 @tail=2, @wi
dth=1, @text="[...
...">, #<PrettyPrint::Group:0x81a0a68 @group=2, @tail=1, @buf=[#<Pre
ttyPrint::Text:0x81a09f0 @tail=1, @width=1, @text="1">], @singleline_width=1>, #
<PrettyPrint::Text:0x81a0a7c @tail=0, @width=1, @text=",">, #<PrettyPrint::Break
able:0x81a0a2c @group=2, @gensace=#<Proc:0x81a0cc0>, @newline="\n"...
...カスタマイズ

あるクラスの pp の出力をカスタマイズしたい場合は、
そのクラスで pretty_print メソッドと pretty_print_cycle メソッドを再定義します。
このメソッドは PP オブジェクトを引数として pp 実行時に呼ばれます。
ユー...

Object#pretty_print(pp) -> () (112.0)

PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。

...ブジェクトです。

//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...