Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > prettyprintライブラリ > PrettyPrintクラス
クラスの継承リスト: PrettyPrint < Object < Kernel < BasicObject
pretty printing アルゴリズムのためのクラスです。 改行の位置を探し、きれいなインデントを施します。
デフォルトでは、このクラスは文字列を扱います。 また、文字1バイトが出力幅の中で1カラムを占めると仮定しています。 しかし、以下のメソッドに対して適切な引数を与えることで、 そうでない場合にも利用できます。
ですので、このクラスは以下のようなことにも応用が可能です。
定義 | 説明 | |
---|---|---|
format(output = '', maxwidth = 79, newline = "\n", genspace = lambda{|n| ' ' * n}) {|pp| ...} -> object
|
PrettyPrint オブジェクトを生成し、それを引数としてブロックを実行します。 与えられた output を返します。 |
|
new(output = '', maxwidth = 79, newline = "\n") -> PrettyPrint
|
pretty printing のためのバッファを生成します。 output は出力先です。output は << メソッドを持っていなければなりません。 << メソッドには
のどれかひとつが引数として与えられます。 |
|
singleline_format(output = '', maxwidth = 79, newline = "\n", genspace = lambda{|n| ' ' * n}) {|pp| ...} -> object
|
PrettyPrint オブジェクトを生成し、それを引数としてブロックを実行します。 PrettyPrint.format に似ていますが、改行しません。 |
定義 | 説明 | |
---|---|---|
breakable(sep = ' ') -> ()
|
「必要ならここで改行出来る」ということを自身に通知します。 もしその位置で改行されなければ、width カラムのテキスト sep が出力の際にそこに挿入されます。 |
|
first? -> bool
|
このメソッドは obsolete です。 |
|
flush -> ()
|
バッファされたデータを出力します。 |
|
genspace -> Proc
|
空白を生成する Proc を返します。 |
|
group(indent = 0, open_obj = '', close_obj = '', open_width = open_obj.length, close_width = close_obj.length) {...} -> ()
|
与えられたブロックを実行します。 ブロック内で自身に追加される文字列やオブジェクトは、1行にまとめて表示しても よい同じグループに属すると仮定されます。 |
|
indent -> Integer
|
現在のインデントの深さを返します。 |
|
maxwidth -> Integer
|
自身の幅を返します。 |
|
nest(indent) {...} -> ()
|
自身の現在のインデントを indent だけ増加させてから、ブロックを実行し、元に戻します。 |
|
newline -> String
|
自身の改行文字を返します。 |
|
output -> object
|
自身の output を返します。 |
|
text(obj) -> ()
|
obj を width カラムのテキストとして自身に追加します。 |
!
!=
==
===
=~
__id__
__send__
_dump
class
clone
dclone
display
enum_for
eql?
equal?
extend
freeze
frozen?
hash
initialize
initialize_copy
inspect
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
marshal_dump
marshal_load
method
method_missing
methods
must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_within_epsilon
must_equal
must_include
must_match
must_raise
must_respond_to
must_send
must_throw
nil?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
public_methods
remove_instance_variable
respond_to?
respond_to_missing?
singleton_class
singleton_method_added
singleton_method_removed
singleton_method_undefined
singleton_methods
taint
tainted?
tap
to_a
to_ary
to_hash
to_int
to_io
to_proc
to_regexp
to_s
to_str
to_yaml
to_yaml_properties
to_yaml_style
trust
untaint
untrust
untrusted?
wont_be
wont_be_close_to
wont_be_empty
wont_be_instance_of
wont_be_kind_of
wont_be_nil
wont_be_same_as
wont_be_within_epsilon
wont_equal
wont_include
wont_match
wont_respond_to