End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
PrettyPrint#text
text(obj, width=obj.length)
lib/prettyprint.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/prettyprint.rb, line 180
def text(obj, width=obj.length)
if @buffer.empty?
@output << obj
@output_width += width
else
text = @buffer.last
unless Text === text
text = Text.new
@buffer << text
end
text.add(obj, width)
@buffer_width += width
break_outmost_groups
end
end
This adds obj as a text of width columns in width.
If width is not specified, obj.length is used.