active_object 5.14.0 → 5.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e9e4059ac3952fe095804bde2546b1b3c454fb765d75127c3b9be2755eba4e9
4
- data.tar.gz: 4eb14d7f25aa5cc39e47fc2d1905c3e5eafb9a0a2eace29d1dc6491f44b4225b
3
+ metadata.gz: cb19625019f41c64b80e88adeaff3bb7871e43a21d6886ffa74fa04e9a28b9f4
4
+ data.tar.gz: a12e3daa0636b987824b717ab5572ed85cba1df7e2f65ba16f744bd7136c9238
5
5
  SHA512:
6
- metadata.gz: cea40c891e09ff82a93f9d14e38b8d36588d5171466decd3a47a75001c16c16563b9341d94f628c55231c5f6d07db3e27bef3478244480b450648ef5ef02bf44
7
- data.tar.gz: 1616bc2b796cd183f6a43fa7c1f3a5ec4b89d99fedf159152948a4fac0f770cd5e46e20e2bbfacf2e66f92b8a71535be4d277f38eefc954fe440af3c6278fb20
6
+ metadata.gz: 6a8f4e1f9915e0e4d692e2d2efa7683d2ecaf9d3c2894dc5d3080537f6672eb54348e40150d2a6acbcf747fb3f40b4306adf419d84b561a44b8103d2a8bdb3f3
7
+ data.tar.gz: f8363de0e1e69f15809ecaffa530ceca2b4407e96e92196d63ec6cb62dc4be1bd4dc932fc2c1f1290f4626f386718f19cd6a1eb854c8e450f78e7816c44042be
@@ -231,13 +231,17 @@ if ActiveObject.configuration.autoload_enumerable
231
231
  return identity unless length.positive?
232
232
 
233
233
  collection_sorted = sort
234
- rank = (num.to_f / 100) * (length + 1)
235
- return collection_sorted[rank - 1] unless rank.fraction?
236
-
237
- truncated_rank = rank.truncate
238
- sample_one = collection_sorted[truncated_rank - 1]
239
- sample_two = collection_sorted[truncated_rank]
240
- (rank.fraction * (sample_two - sample_one)) + sample_one
234
+ index = (num.to_f / 100) * collection_sorted.length - 1
235
+
236
+ if index != index.to_i
237
+ collection_sorted[index.ceil] || identity
238
+ elsif collection_sorted.length.even?
239
+ sample_one = collection_sorted.at(index)
240
+ sample_two = collection_sorted.at(index + 1)
241
+ (sample_one + sample_two) / 2
242
+ else
243
+ collection_sorted[index] || identity
244
+ end
241
245
  end
242
246
  # rubocop:enable Metrics/AbcSize
243
247
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveObject
4
- VERSION ||= '5.14.0'
4
+ VERSION ||= '5.14.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.14.0
4
+ version: 5.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez