about summary refs log tree commit diff stats
path: root/code/extensions/basic.rb
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-03 17:19:52 +0200
committerhut <hut@lavabit.com>2009-07-03 17:19:52 +0200
commitf8634dd6d2477d1871764982fe8d55f2003ab938 (patch)
tree5d278f4fd3538a2d990cd78450d0e883d0fbce1d /code/extensions/basic.rb
parent27ebfe639466906a9bdaeb3a8ade280e07921122 (diff)
downloadranger-f8634dd6d2477d1871764982fe8d55f2003ab938.tar.gz
option to show ascii only and replace non-ascii with *
Diffstat (limited to 'code/extensions/basic.rb')
-rw-r--r--code/extensions/basic.rb8
1 files changed, 8 insertions, 0 deletions
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