I know it's abandoned gem. But seems like here should be < instead of <=.
The lib normalizes {zero: 0, one: 1} to {zero: 0.0, one: 1.0}.
It's obvious that :zero can never be sampled. But rand method can return value 0.0, then pick = 0.0, and then return key if pick <= weight returns :zero since 0.0 <= 0.0 evaluates to true.
I know it's abandoned gem. But seems like here should be
<instead of<=.The lib normalizes
{zero: 0, one: 1}to{zero: 0.0, one: 1.0}.It's obvious that
:zerocan never be sampled. Butrandmethod can return value0.0, thenpick = 0.0, and thenreturn key if pick <= weightreturns:zerosince0.0 <= 0.0evaluates totrue.