method
truncate_text
truncate_text(text, description, max_length = 100_000)
public
Hide source
# File lib/rubygems/text.rb, line 16 def truncate_text(text, description, max_length = 100_000) raise ArgumentError, "max_length must be positive" unless max_length > 0 return text if text.size <= max_length "Truncating #{description} to #{max_length.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse} characters:\n" + text[0, max_length] end