Module: RegexpExamples::RandomResultBySample
- Included in:
- BackReferenceGroup, CharGroup, DotGroup, PlaceHolderGroup, SingleCharGroup
- Defined in:
- lib/regexp-examples/groups.rb
Overview
A helper method for mixing in to Group classes… Uses Array#sample to randomly choose one result from all possible examples
Instance Method Summary collapse
Instance Method Details
#random_result ⇒ Object
45 46 47 48 49 |
# File 'lib/regexp-examples/groups.rb', line 45 def random_result result .to_a # In case of lazy enumerator .sample(1) end |