method

truncate_text

Importance_0
v2_5_5 - Show latest stable - 0 notes - Class: Text
truncate_text(text, description, max_length = 100_000) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

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
Register or log in to add new notes.