Module: ArrayExtensions
- Defined in:
- lib/quote.rb
Instance Method Summary collapse
Instance Method Details
#random ⇒ Object
16 17 18 |
# File 'lib/quote.rb', line 16 def random self[rand(self.size)] end |
#where(criteria = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/quote.rb', line 6 def where(criteria ={}) result = self criteria.each do |cr_key, cr_value| result = result.select do |hash| hash[cr_key].to_s.match(/#{cr_value}/i) end end result end |