Module: ArrayExtensions

Defined in:
lib/quote.rb

Instance Method Summary collapse

Instance Method Details

#randomObject



17
18
19
# File 'lib/quote.rb', line 17

def random
  self[rand(self.size)]
end

#where(criteria = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/quote.rb', line 7

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