summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorDmitry Kim <dmitry point kim at gmail point com>2007-05-10 23:24:21 +0000
committerDmitry Kim <dmitry point kim at gmail point com>2007-05-10 23:24:21 +0000
commit6b4b057692a21a76cc0aaf5d1149cd860810511d (patch)
treeffb2855d889742c531d5ece55f35a6af922f7b96 /lib/rbot
parent7a5fd54f6deb59717cf0de275d285ffe4102ddae (diff)
+ (extends) :limit option support in ircify_html()
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/extends.rb10
1 files changed, 7 insertions, 3 deletions
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