quandl_cassinatra 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
@@ -62,14 +62,19 @@ module Searchable
|
|
62
62
|
search_scope :row, ->(value){
|
63
63
|
# ensure integer
|
64
64
|
value = value.to_i
|
65
|
+
# 0 is the current observation
|
66
|
+
if value == 0
|
67
|
+
order(:desc)
|
68
|
+
limit( 1 )
|
65
69
|
# negative value implies ascending order
|
66
|
-
|
70
|
+
elsif value < 0
|
67
71
|
order(:asc)
|
68
72
|
offset( ( value * -1 ) - 1 )
|
69
73
|
limit( 1 )
|
74
|
+
# postive value is an offset of current observation
|
70
75
|
else
|
71
76
|
order(:desc)
|
72
|
-
offset( value )
|
77
|
+
offset( value - 1 )
|
73
78
|
limit(1)
|
74
79
|
end
|
75
80
|
}
|