lib/redis/list.rb in redis-objects-0.5.1 vs lib/redis/list.rb in redis-objects-0.5.2
- old
+ new
@@ -53,10 +53,11 @@
# Same functionality as Ruby arrays. If a single number is given, return
# just the element at that index using Redis: LINDEX. Otherwise, return
# a range of values using Redis: LRANGE.
def [](index, length=nil)
if index.is_a? Range
- range(index.first, index.last)
+ last = index.exclude_end? ? (index.last - 1) : index.last
+ range(index.first, last)
elsif length
case length <=> 0
when 1 then range(index, index + length - 1)
when 0 then []
when -1 then nil # Ruby does this (a bit weird)