text-gen 0.4.5 → 0.4.6
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 +4 -4
- data/lib/text/gen/runner.rb +2 -2
- data/lib/text/gen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7818963b925f0327e1788fac07898d955c4197721a901a38f83f5311355a81fd
|
|
4
|
+
data.tar.gz: e3620212fb2ea2154b1e06444c875462e7c68a1c60a2c6fb45a92b28729a60a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '048df93a9adb0c5764fd55e90e0bffceacc7f078b5741a8f7c30365755570043101fa7668969a67d6588a17da126945ba0f0d5e4e413a112d4ec4b13d7af5acf'
|
|
7
|
+
data.tar.gz: 244bddd0a689bc18451dc780fa7604a0fbf326ad591fadf9aecf6cb20e203ad31837f8da6c7ab8a9f2240dfbab743523f900a3234243becba538a70dbd471136
|
data/lib/text/gen/runner.rb
CHANGED
|
@@ -99,11 +99,11 @@ module Text
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def run_weighted_items(items, meta, depth)
|
|
102
|
-
total_weight = items.sum { |item| item.fetch("weight", 1).to_i }
|
|
102
|
+
total_weight = items.sum { |item| [item.fetch("weight", 1).to_i, 1].max }
|
|
103
103
|
rand_weight = rand(total_weight)
|
|
104
104
|
current_weight = 0
|
|
105
105
|
item = items.find do |item|
|
|
106
|
-
current_weight += item.fetch("weight", 1).to_i
|
|
106
|
+
current_weight += [item.fetch("weight", 1).to_i, 1].max
|
|
107
107
|
current_weight > rand_weight
|
|
108
108
|
end
|
|
109
109
|
return unless item
|
data/lib/text/gen/version.rb
CHANGED