Class: OverwatchStats::Hero

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

Overview

OverwatchStats::Hero.scrapehero

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#abilitiesObject

Returns the value of attribute abilities.



4
5
6
# File 'lib/hero.rb', line 4

def abilities
  @abilities
end

#ammoObject

Returns the value of attribute ammo.



4
5
6
# File 'lib/hero.rb', line 4

def ammo
  @ammo
end

#hpObject

Returns the value of attribute hp.



4
5
6
# File 'lib/hero.rb', line 4

def hp
  @hp
end

#loreObject

Returns the value of attribute lore.



4
5
6
# File 'lib/hero.rb', line 4

def lore
  @lore
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/hero.rb', line 4

def name
  @name
end

#roleObject

Returns the value of attribute role.



4
5
6
# File 'lib/hero.rb', line 4

def role
  @role
end

Class Method Details

.bastionObject



47
48
49
50
# File 'lib/hero.rb', line 47

def self.bastion
  bastion = self.scrapehero("http://masteroverwatch.com/heroes/15-bastion")
  bastion
end

.dvaObject



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

.genjiObject



57
58
59
60
# File 'lib/hero.rb', line 57

def self.genji
  genji = self.scrapehero("http://masteroverwatch.com/heroes/21-genji")
  genji
end

.hanzoObject



62
63
64
65
# File 'lib/hero.rb', line 62

def self.hanzo
  hanzo = self.scrapehero("http://masteroverwatch.com/heroes/16-hanzo")
  hanzo
end

.junkratObject



67
68
69
70
# File 'lib/hero.rb', line 67

def self.junkrat
  junkray = self.scrapehero("http://masteroverwatch.com/heroes/2-junkrat")
  junkray
end

.lucioObject



72
73
74
75
# File 'lib/hero.rb', line 72

def self.lucio
  lucio = self.scrapehero("http://masteroverwatch.com/heroes/3-lucio")
  lucio
end

.mccreeObject



77
78
79
80
# File 'lib/hero.rb', line 77

def self.mccree
  mccree = self.scrapehero("http://masteroverwatch.com/heroes/6-mccree")
  mccree
end

.meiObject



82
83
84
85
# File 'lib/hero.rb', line 82

def self.mei
  mei = self.scrapehero("http://masteroverwatch.com/heroes/20-mei")
  mei
end

.mercyObject



87
88
89
90
# File 'lib/hero.rb', line 87

def self.mercy
  mercy = self.scrapehero("http://masteroverwatch.com/heroes/17-mercy")
  mercy
end

.pharahObject



92
93
94
95
# File 'lib/hero.rb', line 92

def self.pharah
  pharah = self.scrapehero("http://masteroverwatch.com/heroes/11-pharah")
  pharah
end

.reaperObject



97
98
99
100
# File 'lib/hero.rb', line 97

def self.reaper
  reaper = self.scrapehero("http://masteroverwatch.com/heroes/8-reaper")
  reaper
end

.reinhardtObject



102
103
104
105
# File 'lib/hero.rb', line 102

def self.reinhardt
  reinhardt = self.scrapehero("http://masteroverwatch.com/heroes/12-reinhardt")
  reinhardt
end

.roadhogObject



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



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

.soldier76Object



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

.symmetraObject



117
118
119
120
# File 'lib/hero.rb', line 117

def self.symmetra
  symmetra = self.scrapehero("http://masteroverwatch.com/heroes/13-symmetra")
  symmetra
end

.torbjornObject



122
123
124
125
# File 'lib/hero.rb', line 122

def self.torbjorn
  torbjorn = self.scrapehero("http://masteroverwatch.com/heroes/14-torbjorn")
  torbjorn
end

.tracerObject



127
128
129
130
# File 'lib/hero.rb', line 127

def self.tracer
  tracer = self.scrapehero("http://masteroverwatch.com/heroes/7-tracer")
  tracer
end

.widowmakerObject



132
133
134
135
# File 'lib/hero.rb', line 132

def self.widowmaker
  widowmaker = self.scrapehero("http://masteroverwatch.com/heroes/9-widowmaker")
  widowmaker
end

.winstonObject



137
138
139
140
# File 'lib/hero.rb', line 137

def self.winston
  winston = self.scrapehero("http://masteroverwatch.com/heroes/10-winston")
  winston
end

.zaryaObject



142
143
144
145
# File 'lib/hero.rb', line 142

def self.zarya
  zarya = self.scrapehero("http://masteroverwatch.com/heroes/5-zarya")
  zarya
end

.zenyattaObject



147
148
149
150
# File 'lib/hero.rb', line 147

def self.zenyatta
  zenyatta = self.scrapehero("http://masteroverwatch.com/heroes/18-zenyatta")
  zenyatta
end