Class: Rbwowhead::WowheadApi

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

Instance Method Summary collapse

Instance Method Details

#get_item(item_id) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rbwowhead.rb', line 12

def get_item(item_id)
  item_url = "http://www.wowhead.com/item=#{item_id}&xml"
  xml = Nokogiri::XML(http_request(item_url))
  
  # Initialize a new Item with the XML Data
  Rbwowhead::Item.new(xml)
end

#http_request(url) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rbwowhead.rb', line 20

def http_request(url)
  req = Net::HTTP::Get.new(url)
req["user-agent"] = 'Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2'

uri = URI.parse(URI.escape(url))
		
http = Net::HTTP.new(uri.host, uri.port)
  
http.start do
  res = http.request req
  res.body
 end
end