From f8634dd6d2477d1871764982fe8d55f2003ab938 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 3 Jul 2009 17:19:52 +0200 Subject: option to show ascii only and replace non-ascii with * --- code/extensions/basic.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'code/extensions') diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb index dd2f0fd0..728af9c3 100644 --- a/code/extensions/basic.rb +++ b/code/extensions/basic.rb @@ -33,6 +33,14 @@ class String end end + def ascii_only() + gsub(/[^!-~\s]/, '*') + end + + def ascii_only_if(bool) + bool ? ascii_only : dup + end + def from_first(str) self.include?(str) ? self [ self.index(str) + str.size .. -1 ] : nil end -- cgit 1.4.1-2-gfad0