diff options
author | hut <hut@lavabit.com> | 2009-07-03 17:19:52 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-03 17:19:52 +0200 |
commit | f8634dd6d2477d1871764982fe8d55f2003ab938 (patch) | |
tree | 5d278f4fd3538a2d990cd78450d0e883d0fbce1d /code/extensions/basic.rb | |
parent | 27ebfe639466906a9bdaeb3a8ade280e07921122 (diff) | |
download | ranger-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.rb | 8 |
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 |