We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0676fa commit 7e58dd5Copy full SHA for 7e58dd5
1 file changed
lib/ranked-model/ranker.rb
@@ -170,8 +170,12 @@ def update_index_from_position
170
position_at :first
171
when Integer
172
neighbors = neighbors_at_position(position)
173
- min = ((neighbors[:lower] && neighbors[:lower].has_rank?) ? neighbors[:lower].rank : RankedModel::MIN_RANK_VALUE)
174
- max = ((neighbors[:upper] && neighbors[:upper].has_rank?) ? neighbors[:upper].rank : RankedModel::MAX_RANK_VALUE)
+ return position_at :first if neighbors[:lower].nil?
+ return position_at :last if neighbors[:upper].nil?
175
+
176
+ min = neighbors[:lower].has_rank? ? neighbors[:lower].rank : RankedModel::MIN_RANK_VALUE
177
+ max = neighbors[:upper].has_rank? ? neighbors[:upper].rank : RankedModel::MAX_RANK_VALUE
178
179
rank_at_average min, max
180
when NilClass
181
if !rank
0 commit comments