5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/d3skills.rb', line 5
def self.get_skills(hero_type, level)
name = hero_type hero_level = level page = Nokogiri::HTML(open("http://www.diablowiki.net/" + name + "_skills"))
skills = {}
page.css('table').each do |table|
unless table.nil?
if table.css('tr').css('td').length == 4
name = table.css('tr').css('a')[0]['title'].strip
level = table.css('tr').css('td')[2].text.strip
skills[level] = [] if skills[level].nil?
skills[level] << name
end
end
end
skills_unlocked = skills[hero_level]
if skills_unlocked == nil
puts "No skill unlocked"
else
puts skills_unlocked
end
end
|