Method: Hash.random
- Defined in:
- lib/propr/random/hash.rb
.random(options = {}, m = Propr::Random) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/propr/random/hash.rb', line 21 def random( = {}, m = Propr::Random) min = [:min] || 0 max = [:max] || 10 pair = yield # @todo: Be sure we created enough *unique* keys # # Hash.random(min: 10) do # # key space could have at most 6 elements # m.sequence([Integer.random(min: 0, max: 5), String.random]) # end # m.bind(Integer.random(.merge(min: min, max: max))) do |size| m.bind(m.sequence([pair]*size)) do |pairs| m.unit(Hash[pairs]) end end end |