Class: Wowr::Classes::InfoCharacter
- Defined in:
- lib/wowr/character.rb
Overview
Made up of two parts, character and charactertab
Direct Known Subclasses
Instance Attribute Summary collapse
-
#agility ⇒ Object
(also: #agi)
readonly
character_tab.
-
#arena_teams ⇒ Object
readonly
character_info.
-
#buffs ⇒ Object
readonly
Returns the value of attribute buffs.
-
#char_url ⇒ Object
readonly
character_info.
-
#debuffs ⇒ Object
readonly
Returns the value of attribute debuffs.
-
#defenses ⇒ Object
readonly
Returns the value of attribute defenses.
-
#faction ⇒ Object
readonly
character_info.
-
#faction_id ⇒ Object
readonly
character_info.
-
#health ⇒ Object
readonly
character_tab.
-
#intellect ⇒ Object
(also: #int)
readonly
character_tab.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#known_titles ⇒ Object
readonly
character_info.
-
#last_modified ⇒ Object
readonly
character_info.
-
#melee ⇒ Object
readonly
Returns the value of attribute melee.
-
#points ⇒ Object
readonly
character_info.
-
#professions ⇒ Object
readonly
Returns the value of attribute professions.
-
#pvp ⇒ Object
readonly
Returns the value of attribute pvp.
-
#ranged ⇒ Object
readonly
Returns the value of attribute ranged.
-
#resistances ⇒ Object
readonly
Returns the value of attribute resistances.
-
#second_bar ⇒ Object
readonly
character_tab.
-
#spell ⇒ Object
readonly
Returns the value of attribute spell.
-
#spirit ⇒ Object
(also: #spi)
readonly
character_tab.
-
#stamina ⇒ Object
(also: #sta)
readonly
character_tab.
-
#strength ⇒ Object
(also: #str)
readonly
character_tab.
-
#talent_spec ⇒ Object
readonly
Returns the value of attribute talent_spec.
-
#title ⇒ Object
readonly
character_info.
Attributes inherited from Character
#battle_group, #contribution, #gender, #gender_id, #guild, #guild_id, #guild_url, #klass, #klass_id, #last_login, #level, #name, #race, #race_id, #rank, #realm, #relevance, #search_rank, #season_games_played, #season_games_won, #team_rank, #url
Instance Method Summary collapse
-
#character_info(elem) ⇒ Object
<character battleGroup=“Conviction” charUrl=“r=Genjuros&n=Jonlok” class=“Warlock” classId=“9” faction=“Horde” factionId=“1” gender=“Male” genderId=“0” guildName=“” lastModified=“12 February 2008” level=“41” name=“Jonlok” prefix=“” points=“2270” race=“Orc” raceId=“2” realm=“Genjuros” suffix=“”/>.
- #character_tab(elem) ⇒ Object
-
#initialize(sheet, api = nil) ⇒ InfoCharacter
constructor
It’s made up of two parts Don’t care about battlegroups yet I don’t think I can call stuff from the constructor?.
Methods inherited from Character
#class_icon, #icon, #race_icon
Constructor Details
#initialize(sheet, api = nil) ⇒ InfoCharacter
It’s made up of two parts Don’t care about battlegroups yet I don’t think I can call stuff from the constructor?
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/wowr/character.rb', line 158 def initialize(sheet, api = nil) @api = api character_info(sheet%'character') # Check if characterTab is defined. If not, the character have no infos on the armory (not logged since last armory wipe) raise Wowr::Exceptions::CharacterNoInfo.new(@name) if (sheet%'characterTab').nil? character_tab(sheet%'characterTab') end |
Instance Attribute Details
#agility ⇒ Object (readonly) Also known as: agi
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def agility @agility end |
#arena_teams ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def arena_teams @arena_teams end |
#buffs ⇒ Object (readonly)
Returns the value of attribute buffs.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def buffs @buffs end |
#char_url ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def char_url @char_url end |
#debuffs ⇒ Object (readonly)
Returns the value of attribute debuffs.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def debuffs @debuffs end |
#defenses ⇒ Object (readonly)
Returns the value of attribute defenses.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def defenses @defenses end |
#faction ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def faction @faction end |
#faction_id ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def faction_id @faction_id end |
#health ⇒ Object (readonly)
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def health @health end |
#intellect ⇒ Object (readonly) Also known as: int
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def intellect @intellect end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def items @items end |
#known_titles ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def known_titles @known_titles end |
#last_modified ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def last_modified @last_modified end |
#melee ⇒ Object (readonly)
Returns the value of attribute melee.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def melee @melee end |
#points ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def points @points end |
#professions ⇒ Object (readonly)
Returns the value of attribute professions.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def professions @professions end |
#pvp ⇒ Object (readonly)
Returns the value of attribute pvp.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def pvp @pvp end |
#ranged ⇒ Object (readonly)
Returns the value of attribute ranged.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def ranged @ranged end |
#resistances ⇒ Object (readonly)
Returns the value of attribute resistances.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def resistances @resistances end |
#second_bar ⇒ Object (readonly)
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def @second_bar end |
#spell ⇒ Object (readonly)
Returns the value of attribute spell.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def spell @spell end |
#spirit ⇒ Object (readonly) Also known as: spi
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def spirit @spirit end |
#stamina ⇒ Object (readonly) Also known as: sta
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def stamina @stamina end |
#strength ⇒ Object (readonly) Also known as: str
character_tab
140 141 142 |
# File 'lib/wowr/character.rb', line 140 def strength @strength end |
#talent_spec ⇒ Object (readonly)
Returns the value of attribute talent_spec.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def talent_spec @talent_spec end |
#title ⇒ Object (readonly)
character_info
133 134 135 |
# File 'lib/wowr/character.rb', line 133 def title @title end |
Instance Method Details
#character_info(elem) ⇒ Object
<character
battleGroup="Conviction"
charUrl="r=Genjuros&n=Jonlok"
class="Warlock"
classId="9"
faction="Horde"
factionId="1"
gender="Male"
genderId="0"
guildName=""
lastModified="12 February 2008"
level="41"
name="Jonlok"
prefix=""
points="2270"
race="Orc"
raceId="2"
realm="Genjuros"
suffix=""/>
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/wowr/character.rb', line 189 def character_info(elem) # basic info @name = elem[:name] @level = elem[:level].to_i @char_url = elem[:charUrl] @klass = elem[:class] @klass_id = elem[:classId].to_i @gender = elem[:gender] @gender_id = elem[:genderId].to_i @race = elem[:race] @race_id = elem[:raceId].to_i @faction = elem[:faction] @faction_id = elem[:factionId].to_i @guild = elem[:guildName] == "" ? nil : elem[:guildName] @guild_url = elem[:guildUrl] == "" ? nil : elem[:guildUrl] @prefix = elem[:prefix] == "" ? nil : elem[:prefix] @suffix = elem[:suffix] == "" ? nil : elem[:suffix] @points = elem[:points].to_i @realm = elem[:realm] @battle_group = elem[:battleGroup] # format is February 11, 2008 # except when it's korean, and then it's 2008년 5월 11일 (일) # tw is 2008年5月11日 (2008年5月11日) # TODO: Datetime doesn't parse other languages nicely # Until then, just save it as a string begin @last_modified = elem[:lastModified] == "" ? nil : DateTime.parse(elem[:lastModified]) rescue @last_modified = elem[:lastModified] == "" ? nil : elem[:lastModified] end #@last_modified = elem[:lastModified]#.to_time @arena_teams = [] (elem/:arenaTeam).each do |arena_team| @arena_teams << ArenaTeam.new(arena_team) end end |
#character_tab(elem) ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/wowr/character.rb', line 238 def character_tab(elem) # <title value=""/> @title = (elem%'title')[:value] == "" ? nil : (elem%'title')[:value] @known_titles = [] @known_titles << @title if (@title) (elem%'knownTitles'/:title).each do |entry| @known_titles << entry[:value] if (!@known_titles.include?(entry[:value])) end @health = (elem%'characterBars'%'health')[:effective].to_i @second_bar = SecondBar.new(elem%'characterBars'%'secondBar') # base stats @strength = Strength.new(elem%'baseStats'%'strength') @agility = Agility.new(elem%'baseStats'%'agility') @stamina = Stamina.new(elem%'baseStats'%'stamina') @intellect = Intellect.new(elem%'baseStats'%'intellect') @spirit = Spirit.new(elem%'baseStats'%'spirit') # damage stuff @melee = Melee.new(elem%'melee') @ranged = Ranged.new(elem%'ranged') @spell = Spell.new(elem.at(' > spell')) # TODO: hacky? @defenses = Defenses.new(elem%'defenses') # TODO: Massive problem, doesn't fill in resistances for some reason resist_types = ['arcane', 'fire', 'frost', 'holy', 'nature', 'shadow'] @resistances = {} resist_types.each do |res| @resistances[res] = Resistance.new(elem%'resistances'%res) end @talent_spec = TalentSpec.new(elem%'talentSpec') @pvp = Pvp.new(elem%'pvp') @professions = [] (elem%'professions'/:skill).each do |skill| @professions << Skill.new(skill) end @items = [] (elem%'items'/:item).each do |item| @items << EquippedItem.new(item, @api) end @buffs = [] (elem%'buffs'/:spell).each do |buff| @buffs << Buff.new(buff, @api) end @debuffs = [] (elem%'debuffs'/:spell).each do |debuff| @debuffs << Buff.new(debuff, @api) end end |