diff options
author | hut <hut@lavabit.com> | 2009-07-24 02:05:20 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-24 02:05:20 +0200 |
commit | caf93a12841e8a001c338045c7e17ed0622ec8ce (patch) | |
tree | 1a63e76e920d74094af43d5d2b994064116dca57 /code | |
parent | 355311b78be9df14629212e66b5cefa35f2873e8 (diff) | |
download | ranger-caf93a12841e8a001c338045c7e17ed0622ec8ce.tar.gz |
implement Array#wrap for n < 0
Diffstat (limited to 'code')
-rw-r--r-- | code/extensions/basic.rb | 6 |
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] |