output

output(out, output_width) Instance Public methods

format

format(output='', maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n}) Class Public methods This is a convenience method which is same as follows: begin q = PrettyPrint.new(output, maxwidth, newline, &genspace) ... q.flush output end

new

new(output='', maxwidth=79, newline="\n", &genspace) Class Public methods Creates a buffer for pretty printing. output is an output target. If it is not specified, '' is assumed. It should have a << method which accepts the first argument obj of #text, the first argument sep of #breakable, the first argument newline of ::new, and the result of a given block for ::new. maxwidth specifies maximum line length. If it is not specified, 79 is assumed. However actual outputs may

singleline_format

singleline_format(output='', maxwidth=nil, newline=nil, genspace=nil) Class Public methods This is similar to ::format but the result has no breaks. maxwidth, newline and genspace are ignored. The invocation of breakable in the block doesn't break a line and is treated as just an invocation of text.

break_outmost_groups

break_outmost_groups() Instance Public methods Breaks the buffer into lines that are shorter than maxwidth

breakable

breakable(sep=' ', width=sep.length) Instance Public methods This says âyou can break a line here if necessaryâ, and a width-column text sep is inserted if a line is not broken at the point. If sep is not specified, â â is used. If width is not specified, sep.length is used. You will have to specify this when sep is a multibyte character, for example.

current_group

current_group() Instance Public methods Returns the group most recently added to the stack.

fill_breakable

fill_breakable(sep=' ', width=sep.length) Instance Public methods This is similar to breakable except the decision to break or not is determined individually. Two fill_breakable under a group may cause 4 results: (break,break), (break,non-break), (non-break,break), (non-break,non-break). This is different to breakable because two breakable under a group may cause 2 results: (break,break), (non-break,non-break). The text sep+ is inserted if a line is not broken at this point. If sep

first?

first?() Instance Public methods first? is a predicate to test the call is a first call to first? with current group. It is useful to format comma separated values as: q.group(1, '[', ']') { xxx.each {|yyy| unless q.first? q.text ',' q.breakable end ... pretty printing yyy ... } } first? is obsoleted in 1.8.2.

flush

flush() Instance Public methods outputs buffered data.