kujibiki 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kujibiki/core_ext/array.rb +3 -1
- data/lib/kujibiki/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eccc6d249e913c599a87624d0300d6ea0b7f1a02
|
4
|
+
data.tar.gz: d2e1a47e35a35ec9ae9e1879902095515e34e63a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e70ca7f2a0fff49e0dc17cc41585d92cdd26ef2883c35cbe80a3da448c92b0897a6940752670b5a1a3bd3d30c8baba065ed18dbe8b357b25e888ad5af9f054
|
7
|
+
data.tar.gz: db6ca4c61023f89d05d4201010223afc42609e0eba9733ecbb593ce93483f1b10def4b5c1d29169f206c3f98434d96645194e704256183c05cde332c268ff3b8
|
@@ -4,9 +4,11 @@ class Array
|
|
4
4
|
return call_original_sample(n, random: random) if (weight.nil? || self.size <= 1)
|
5
5
|
|
6
6
|
unless weight.select {|w| w > 0}.size >= self.size
|
7
|
-
raise ArgumentError, "weight size must be
|
7
|
+
raise ArgumentError, "weight size must be equal to array size(#{self.size})"
|
8
8
|
end
|
9
9
|
|
10
|
+
n = self.size if n > self.size
|
11
|
+
|
10
12
|
begin
|
11
13
|
sum = weight.inject(0.0, :+)
|
12
14
|
normalized_hash = self.each_with_object({}).with_index do |(e, h), i|
|
data/lib/kujibiki/version.rb
CHANGED