Module: Fargo::Supports::Searches
Instance Method Summary collapse
- #remove_search(search) ⇒ Object
- #search(search) ⇒ Object
- #search_hub(query) ⇒ Object
- #search_objects ⇒ Object
- #search_results(search) ⇒ Object
- #searches ⇒ Object
Instance Method Details
#remove_search(search) ⇒ Object
46 47 48 49 50 |
# File 'lib/fargo/supports/searches.rb', line 46 def remove_search search search = normalize search @searches.delete search.to_s @search_objects.delete search.to_s end |
#search(search) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fargo/supports/searches.rb', line 22 def search search raise ConnectionException.new 'Not connected yet!' unless connected? search = normalize search @searches[search.to_s] = [] @search_objects[search.to_s] = search search_hub search EventMachine.add_timer(600) { remove_search search } end |
#search_hub(query) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fargo/supports/searches.rb', line 10 def search_hub query raise ConnectionError.new('Not connected Yet!') unless connected? if config.passive location = "Hub:#{config.nick}" else location = "#{config.address}:#{config.search_port}" end hub. 'Search', "#{location} #{query.to_s}" end |
#search_objects ⇒ Object
37 38 39 |
# File 'lib/fargo/supports/searches.rb', line 37 def search_objects @searches.keys.map { |k| @search_objects[k] } end |
#search_results(search) ⇒ Object
41 42 43 44 |
# File 'lib/fargo/supports/searches.rb', line 41 def search_results search search = normalize search @searches[search.to_s] end |
#searches ⇒ Object
33 34 35 |
# File 'lib/fargo/supports/searches.rb', line 33 def searches search_objects.map{ |s| s.query } end |