Class: Elekk::Wowhead

Inherits:
Object
  • Object
show all
Defined in:
lib/elekk/wowhead.rb

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.search(term) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/elekk/wowhead.rb', line 5

def self.search(term)
  resp = HTTP.json('http://www.wowhead.com/search', {:q => term, :opensearch => nil}, :cache_timeout => 60)
  data = []
  resp[1].each_with_index do |v,i|
    d = resp[7][i]
    kind = Kind[d[0]]
    data.push Result.new d[1], v.gsub(/\s*\(#{kind}\)$/, ''), kind, d[2], d[3]
  end
  data
end