about summary refs log tree commit diff stats
path: root/code/extensions
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-13 02:20:46 +0200
committerhut <hut@lavabit.com>2009-06-13 02:20:46 +0200
commit2887ca25fb58362d5d644ecda5f0bc51c80ec404 (patch)
treeb066f5542d97b1a4a9134d0910692b873fe32363 /code/extensions
parent325ec37f65172b5b640d998eba300d86d1ddbfa5 (diff)
downloadranger-2887ca25fb58362d5d644ecda5f0bc51c80ec404.tar.gz
rewrite of the way files are executed, easier config
Diffstat (limited to 'code/extensions')
-rw-r--r--code/extensions/basic.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb
index 1bc67519..1e890a04 100644
--- a/code/extensions/basic.rb
+++ b/code/extensions/basic.rb
@@ -8,6 +8,7 @@ class MutableNumber
 	end
 	def add(n=1) @value += n end
 	def sub(n=1) @value -= n end
+	def set(n)   @value  = n end
 end
 
 class Array
@@ -15,6 +16,10 @@ class Array
 		# TODO: this can be done better...
 		n.times { push shift }
 	end
+	def cdr(n = 1)
+		self[n .. -1]
+	end
+	alias car first
 end
 
 class String
@@ -65,6 +70,14 @@ class String
 		res.gsub!("\000", '\\\\')
 		return res
 	end
+
+	## encodes a string for the shell.
+	##   peter's song.mp3 -> 'peter'\''s song.mp3'
+	##
+	##   system("mplayer #{ ~some_video_file }")
+	def ~
+		"'#{ gsub("'", "'\\\\''") }'"
+	end
 end
 
 class Numeric