Method: PrettyPrint#breakable

Defined in:
lib/prettyprint.rb

#breakable(sep = ' ', width = sep.length) ⇒ Object

This tells “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.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/prettyprint.rb', line 172

def breakable(sep=' ', width=sep.length)
  group = @group_stack.last
  if group.break?
    flush
    @output << @newline
    @output << @genspace.call(@indent)
    @output_width = @indent
    @buffer_width = 0
  else
    @buffer << Breakable.new(sep, width, self)
    @buffer_width += width
    break_outmost_groups
  end
end