Class: Voom::Presenters::Demo::Search
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Voom::Presenters::Demo::Search
- Defined in:
- lib/voom/presenters/demo/search.rb
Instance Method Summary collapse
Instance Method Details
#search(term) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/voom/presenters/demo/search.rb', line 12 def search(term) require 'yaml' return [] unless term @terms ||= YAML::load_file(File.join(__dir__, './search-terms.yml')) @terms.keys.reduce([]) do |matches, topic| @terms[topic].reduce(matches) do |matches, item| matches << [item, matches.length] if item.downcase.include?(term.downcase) matches end end end |