4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/stair_car/shared/indicies.rb', line 4
def convert_indicies(index, max_index)
if index.is_a?(Fixnum)
if index < 0
return [max_index + index]
else
return [index]
end
elsif index.is_a?(Array)
return index.map {|i| convert_indicies(i, max_index) }.flatten
elsif index.is_a?(Range)
if index.end < 0
start = index.begin
new_end = max_index + index.end
if index.exclude_end?
index = (start...new_end)
else
index = (start..new_end)
end
end
return index.to_a
elsif index.is_a?(NilClass)
return nil.to_java end
end
|