Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
PrettyPrint#breakable
(?::String sep, ?::Integer width) -> void
breakable(sep=' ', width=sep.length)
lib/prettyprint.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/prettyprint.rb, line 226
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
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.
See also
.singleline_format
#break_outmost_groups
.new
#current_group
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0