Class: OverwatchStats::Hero
- Inherits:
-
Object
- Object
- OverwatchStats::Hero
- Defined in:
- lib/hero.rb
Overview
OverwatchStats::Hero.scrapehero
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#abilities ⇒ Object
Returns the value of attribute abilities.
-
#ammo ⇒ Object
Returns the value of attribute ammo.
-
#hp ⇒ Object
Returns the value of attribute hp.
-
#lore ⇒ Object
Returns the value of attribute lore.
-
#name ⇒ Object
Returns the value of attribute name.
-
#role ⇒ Object
Returns the value of attribute role.
Class Method Summary collapse
- .bastion ⇒ Object
- .dva ⇒ Object
- .genji ⇒ Object
- .hanzo ⇒ Object
- .junkrat ⇒ Object
- .lucio ⇒ Object
- .mccree ⇒ Object
- .mei ⇒ Object
- .mercy ⇒ Object
- .pharah ⇒ Object
- .reaper ⇒ Object
- .reinhardt ⇒ Object
- .roadhog ⇒ Object
-
.scrapehero(page_url) ⇒ Object
@@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”].
- .soldier76 ⇒ Object
- .symmetra ⇒ Object
- .torbjorn ⇒ Object
- .tracer ⇒ Object
- .widowmaker ⇒ Object
- .winston ⇒ Object
- .zarya ⇒ Object
- .zenyatta ⇒ Object
Instance Attribute Details
#abilities ⇒ Object
Returns the value of attribute abilities.
4 5 6 |
# File 'lib/hero.rb', line 4 def abilities @abilities end |
#ammo ⇒ Object
Returns the value of attribute ammo.
4 5 6 |
# File 'lib/hero.rb', line 4 def ammo @ammo end |
#hp ⇒ Object
Returns the value of attribute hp.
4 5 6 |
# File 'lib/hero.rb', line 4 def hp @hp end |
#lore ⇒ Object
Returns the value of attribute lore.
4 5 6 |
# File 'lib/hero.rb', line 4 def lore @lore end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/hero.rb', line 4 def name @name end |
#role ⇒ Object
Returns the value of attribute role.
4 5 6 |
# File 'lib/hero.rb', line 4 def role @role end |
Class Method Details
.bastion ⇒ Object
47 48 49 50 |
# File 'lib/hero.rb', line 47 def self.bastion bastion = self.scrapehero("http://masteroverwatch.com/heroes/15-bastion") bastion end |
.dva ⇒ Object
52 53 54 55 |
# File 'lib/hero.rb', line 52 def self.dva dva = self.scrapehero("http://masteroverwatch.com/heroes/22-d-va") dva end |
.genji ⇒ Object
57 58 59 60 |
# File 'lib/hero.rb', line 57 def self.genji genji = self.scrapehero("http://masteroverwatch.com/heroes/21-genji") genji end |
.hanzo ⇒ Object
62 63 64 65 |
# File 'lib/hero.rb', line 62 def self.hanzo hanzo = self.scrapehero("http://masteroverwatch.com/heroes/16-hanzo") hanzo end |
.junkrat ⇒ Object
67 68 69 70 |
# File 'lib/hero.rb', line 67 def self.junkrat junkray = self.scrapehero("http://masteroverwatch.com/heroes/2-junkrat") junkray end |
.lucio ⇒ Object
72 73 74 75 |
# File 'lib/hero.rb', line 72 def self.lucio lucio = self.scrapehero("http://masteroverwatch.com/heroes/3-lucio") lucio end |
.mccree ⇒ Object
77 78 79 80 |
# File 'lib/hero.rb', line 77 def self.mccree mccree = self.scrapehero("http://masteroverwatch.com/heroes/6-mccree") mccree end |
.mei ⇒ Object
82 83 84 85 |
# File 'lib/hero.rb', line 82 def self.mei mei = self.scrapehero("http://masteroverwatch.com/heroes/20-mei") mei end |
.mercy ⇒ Object
87 88 89 90 |
# File 'lib/hero.rb', line 87 def self.mercy mercy = self.scrapehero("http://masteroverwatch.com/heroes/17-mercy") mercy end |
.pharah ⇒ Object
92 93 94 95 |
# File 'lib/hero.rb', line 92 def self.pharah pharah = self.scrapehero("http://masteroverwatch.com/heroes/11-pharah") pharah end |
.reaper ⇒ Object
97 98 99 100 |
# File 'lib/hero.rb', line 97 def self.reaper reaper = self.scrapehero("http://masteroverwatch.com/heroes/8-reaper") reaper end |
.reinhardt ⇒ Object
102 103 104 105 |
# File 'lib/hero.rb', line 102 def self.reinhardt reinhardt = self.scrapehero("http://masteroverwatch.com/heroes/12-reinhardt") reinhardt end |
.roadhog ⇒ Object
107 108 109 110 |
# File 'lib/hero.rb', line 107 def self.roadhog roadhog = self.scrapehero("http://masteroverwatch.com/heroes/1-roadhog") roadhog end |
.scrapehero(page_url) ⇒ Object
@@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”]
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 ⇒ Object
112 113 114 115 |
# File 'lib/hero.rb', line 112 def self.soldier76 soldier76 = self.scrapehero("http://masteroverwatch.com/heroes/4-soldier-76") soldier76 end |
.symmetra ⇒ Object
117 118 119 120 |
# File 'lib/hero.rb', line 117 def self.symmetra symmetra = self.scrapehero("http://masteroverwatch.com/heroes/13-symmetra") symmetra end |
.torbjorn ⇒ Object
122 123 124 125 |
# File 'lib/hero.rb', line 122 def self.torbjorn torbjorn = self.scrapehero("http://masteroverwatch.com/heroes/14-torbjorn") torbjorn end |
.tracer ⇒ Object
127 128 129 130 |
# File 'lib/hero.rb', line 127 def self.tracer tracer = self.scrapehero("http://masteroverwatch.com/heroes/7-tracer") tracer end |
.widowmaker ⇒ Object
132 133 134 135 |
# File 'lib/hero.rb', line 132 def self.widowmaker widowmaker = self.scrapehero("http://masteroverwatch.com/heroes/9-widowmaker") widowmaker end |
.winston ⇒ Object
137 138 139 140 |
# File 'lib/hero.rb', line 137 def self.winston winston = self.scrapehero("http://masteroverwatch.com/heroes/10-winston") winston end |
.zarya ⇒ Object
142 143 144 145 |
# File 'lib/hero.rb', line 142 def self.zarya zarya = self.scrapehero("http://masteroverwatch.com/heroes/5-zarya") zarya end |
.zenyatta ⇒ Object
147 148 149 150 |
# File 'lib/hero.rb', line 147 def self.zenyatta zenyatta = self.scrapehero("http://masteroverwatch.com/heroes/18-zenyatta") zenyatta end |