about summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-24 02:05:20 +0200
committerhut <hut@lavabit.com>2009-07-24 02:05:20 +0200
commitcaf93a12841e8a001c338045c7e17ed0622ec8ce (patch)
tree1a63e76e920d74094af43d5d2b994064116dca57 /code
parent355311b78be9df14629212e66b5cefa35f2873e8 (diff)
downloadranger-caf93a12841e8a001c338045c7e17ed0622ec8ce.tar.gz
implement Array#wrap for n < 0
Diffstat (limited to 'code')
-rw-r--r--code/extensions/basic.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb
index b04dc71d..5244a459 100644
--- a/code/extensions/basic.rb
+++ b/code/extensions/basic.rb
@@ -14,7 +14,11 @@ end
 class Array
 	def wrap(n)
 		# TODO: this can be done better...
-		n.times { push shift }
+		if n >= 0
+			n.times { push shift }
+		else
+			n.abs.times { unshift pop }
+		end
 	end
 	def cdr(n = 1)
 		self[n .. -1]