Module: Fargo::Supports::Searches

Extended by:
ActiveSupport::Concern
Included in:
Client
Defined in:
lib/fargo/supports/searches.rb

Instance Method Summary collapse

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

Raises:

  • (ConnectionError)


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.send_message 'Search', "#{location} #{query.to_s}"
end

#search_objectsObject



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

#searchesObject



33
34
35
# File 'lib/fargo/supports/searches.rb', line 33

def searches
  search_objects.map{ |s| s.query }
end