diff options
Diffstat (limited to 'code/extensions')
-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 |