instance method
PrettyPrint#text
(::String obj, ?::Integer width) -> void
text(obj, width=obj.length)
lib/prettyprint.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prettyprint.rb, line 183
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.