class OverwatchStats::Hero

OverwatchStats::Hero.scrapehero

Attributes

abilities[RW]
ammo[RW]
hp[RW]
lore[RW]
name[RW]
role[RW]

Public Class Methods

bastion() click to toggle source
# File lib/hero.rb, line 47
def self.bastion
  bastion = self.scrapehero("http://masteroverwatch.com/heroes/15-bastion")
  bastion
end
dva() click to toggle source
# File lib/hero.rb, line 52
def self.dva
  dva = self.scrapehero("http://masteroverwatch.com/heroes/22-d-va")
  dva
end
genji() click to toggle source
# File lib/hero.rb, line 57
def self.genji
  genji = self.scrapehero("http://masteroverwatch.com/heroes/21-genji")
  genji
end
hanzo() click to toggle source
# File lib/hero.rb, line 62
def self.hanzo
  hanzo = self.scrapehero("http://masteroverwatch.com/heroes/16-hanzo")
  hanzo
end
junkrat() click to toggle source
# File lib/hero.rb, line 67
def self.junkrat
  junkray = self.scrapehero("http://masteroverwatch.com/heroes/2-junkrat")
  junkray
end
lucio() click to toggle source
# File lib/hero.rb, line 72
def self.lucio
  lucio = self.scrapehero("http://masteroverwatch.com/heroes/3-lucio")
  lucio
end
mccree() click to toggle source
# File lib/hero.rb, line 77
def self.mccree
  mccree = self.scrapehero("http://masteroverwatch.com/heroes/6-mccree")
  mccree
end
mei() click to toggle source
# File lib/hero.rb, line 82
def self.mei
  mei = self.scrapehero("http://masteroverwatch.com/heroes/20-mei")
  mei
end
mercy() click to toggle source
# File lib/hero.rb, line 87
def self.mercy
  mercy = self.scrapehero("http://masteroverwatch.com/heroes/17-mercy")
  mercy
end
pharah() click to toggle source
# File lib/hero.rb, line 92
def self.pharah
  pharah = self.scrapehero("http://masteroverwatch.com/heroes/11-pharah")
  pharah
end
reaper() click to toggle source
# File lib/hero.rb, line 97
def self.reaper
  reaper = self.scrapehero("http://masteroverwatch.com/heroes/8-reaper")
  reaper
end
reinhardt() click to toggle source
# File lib/hero.rb, line 102
def self.reinhardt
  reinhardt = self.scrapehero("http://masteroverwatch.com/heroes/12-reinhardt")
  reinhardt
end
roadhog() click to toggle source
# File lib/hero.rb, line 107
def self.roadhog
  roadhog = self.scrapehero("http://masteroverwatch.com/heroes/1-roadhog")
  roadhog
end
scrapehero(page_url) click to toggle source

@@urls = [“masteroverwatch.com/heroes/15-bastion”, “masteroverwatch.com/heroes/22-d-va”, “masteroverwatch.com/heroes/21-genji”, “masteroverwatch.com/heroes/16-hanzo”, “masteroverwatch.com/heroes/2-junkrat”, “masteroverwatch.com/heroes/3-lucio”, “masteroverwatch.com/heroes/6-mccree”, “masteroverwatch.com/heroes/20-mei”, “masteroverwatch.com/heroes/17-mercy”, “masteroverwatch.com/heroes/11-pharah”, “masteroverwatch.com/heroes/8-reaper”, “masteroverwatch.com/heroes/12-reinhardt”, “masteroverwatch.com/heroes/1-roadhog”, “masteroverwatch.com/heroes/4-soldier-76”, “masteroverwatch.com/heroes/13-symmetra”, “masteroverwatch.com/heroes/14-torbjorn”, “masteroverwatch.com/heroes/7-tracer”, “masteroverwatch.com/heroes/9-widowmaker”, “masteroverwatch.com/heroes/10-winston”, “masteroverwatch.com/heroes/5-zarya”, “masteroverwatch.com/heroes/18-zenyatta”]

# File lib/hero.rb, line 30
def self.scrapehero(page_url)
  doc = Nokogiri::HTML(open(page_url))
  x = OverwatchStats::Hero.new
  x.name = doc.css("div.heroes-header-title h1").text
  x.lore = doc.css("div.heroes-lore p").text.gsub(".",". ")
  x.hp = doc.css("div.heroes-header-title span.stat-hp").text.strip + " HP" unless doc.css("div.heroes-header-title span.stat-hp").text.strip == ""
  x.ammo = doc.css("div.heroes-header-title span.stat-ammo").text.strip + " Ammo" unless doc.css("div.heroes-header-title span.stat-ammo").text.strip == ""
  x.abilities = []
  doc.css("div.heroes-abilities-ability").each do |ability|
    ability_name = ability.css("div.ability-name").text
    ability_description = ability.css("div.ability-description").text
    x.abilities << {:ability_name => ability_name, :ability_description => ability_description}
  end
  x.role = doc.css("div.heroes-header-title span.stat-role").text
  x
end
soldier76() click to toggle source
# File lib/hero.rb, line 112
def self.soldier76
  soldier76 = self.scrapehero("http://masteroverwatch.com/heroes/4-soldier-76")
  soldier76
end
symmetra() click to toggle source
# File lib/hero.rb, line 117
def self.symmetra
  symmetra = self.scrapehero("http://masteroverwatch.com/heroes/13-symmetra")
  symmetra
end
torbjorn() click to toggle source
# File lib/hero.rb, line 122
def self.torbjorn
  torbjorn = self.scrapehero("http://masteroverwatch.com/heroes/14-torbjorn")
  torbjorn
end
tracer() click to toggle source
# File lib/hero.rb, line 127
def self.tracer
  tracer = self.scrapehero("http://masteroverwatch.com/heroes/7-tracer")
  tracer
end
widowmaker() click to toggle source
# File lib/hero.rb, line 132
def self.widowmaker
  widowmaker = self.scrapehero("http://masteroverwatch.com/heroes/9-widowmaker")
  widowmaker
end
winston() click to toggle source
# File lib/hero.rb, line 137
def self.winston
  winston = self.scrapehero("http://masteroverwatch.com/heroes/10-winston")
  winston
end
zarya() click to toggle source
# File lib/hero.rb, line 142
def self.zarya
  zarya = self.scrapehero("http://masteroverwatch.com/heroes/5-zarya")
  zarya
end
zenyatta() click to toggle source
# File lib/hero.rb, line 147
def self.zenyatta
  zenyatta = self.scrapehero("http://masteroverwatch.com/heroes/18-zenyatta")
  zenyatta
end