Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/dsl/monkeypatches.rb,
lib/dsl/monkeypatches.rb
Overview
Enchancement of Hash
class to generate random hash of the given size. The hash elements are instances of the samples given. The keys are in the range (‘a’..‘z’). By default, there is a hash having strings and fixnums as values.
Instance Method Summary collapse
-
#∀(size: 64, samples: ["", 1000]) ⇒ Hash
(also: #any)
Generates random sample of
Hash
.
Instance Method Details
#∀(size: 64, samples: ["", 1000]) ⇒ Hash Also known as: any
TODO:
Do we really need to append randoms? Isn’t {}.∀ | {:foo ⇒ 42} clearer?
Note:
When called on non-empty hash, the random elements are added to the existing.
Generates random sample of Hash
.
130 131 132 133 134 135 136 |
# File 'lib/dsl/monkeypatches.rb', line 130 def ∀(size: 64, samples: ["", 1000]) self.dup.tap { |v| size.times { v["".∀(:symbols => [*('a'..'z')])] = ::Kernel::random(:samples => samples) } } end |