about summary refs log tree commit diff stats
path: root/code/extensions
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
parent27ebfe639466906a9bdaeb3a8ade280e07921122 (diff)
downloadranger-f8634dd6d2477d1871764982fe8d55f2003ab938.tar.gz
option to show ascii only and replace non-ascii with *
Diffstat (limited to 'code/extensions')
-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
ref='#n153'>153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221