From 6b4b057692a21a76cc0aaf5d1149cd860810511d Mon Sep 17 00:00:00 2001 From: Dmitry Kim Date: Thu, 10 May 2007 23:24:21 +0000 Subject: + (extends) :limit option support in ircify_html() --- lib/rbot/core/utils/extends.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb index 1aa6d457..80bad383 100644 --- a/lib/rbot/core/utils/extends.rb +++ b/lib/rbot/core/utils/extends.rb @@ -85,8 +85,7 @@ end # Extensions to the String class # -# TODO make ircify_html() accept an Hash of options, and make riphtml() just -# call ircify_html() with stronger purify options. +# TODO make riphtml() just call ircify_html() with stronger purify options. # class ::String @@ -156,9 +155,14 @@ class ::String # And finally whitespace is squeezed txt.gsub!(/\s+/, ' ') + txt.strip! + + if opts[:limit] && txt.size > opts[:limit] + txt = txt.slice(0, opts[:limit]) + "#{Reverse}...#{Reverse}" + end # Decode entities and strip whitespace - return txt.strip + return txt end # As above, but modify the receiver -- cgit v1.2.3