Sha256: 03f3c2f613ff0a427cbe7eb2c0a3cdc39efd5c11fb5d3a359feadb5e9afe97fc
Contents?: true
Size: 627 Bytes
Versions: 1
Compression:
Stored size: 627 Bytes
Contents
class String def squish dup.squish! end def squish! gsub!(/\A[[:space:]]+/, '') gsub!(/[[:space:]]+\z/, '') gsub!(/[[:space:]]+/, ' ') self end def truncate(truncate_at, options = {}) return dup unless length > truncate_at options[:omission] ||= '...' length_with_room_for_omission = truncate_at - options[:omission].length stop = \ if options[:separator] rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission else length_with_room_for_omission end "#{self[0...stop]}#{options[:omission]}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
happy_support-1.0.0 | lib/happy_support/core_ext/string/filters.rb |