Class: Wowr::Classes::FullCharacter
- Defined in:
- lib/wowr/character.rb
Overview
Full character details uses characterInfo element Made up of two parts, character and charactertab
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.
-
#last_modified ⇒ Object
readonly
character_info.
-
#melee ⇒ Object
readonly
Returns the value of attribute melee.
-
#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.
-
#reputation_categories ⇒ Object
(also: #rep, #reputation)
readonly
Returns the value of attribute reputation_categories.
-
#resistances ⇒ Object
readonly
Returns the value of attribute resistances.
-
#second_bar ⇒ Object
readonly
character_tab.
-
#skill_categories ⇒ Object
(also: #skills)
readonly
Returns the value of attribute skill_categories.
-
#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=“” race=“Orc” raceId=“2” realm=“Genjuros” suffix=“”/>.
-
#character_reputation(elem) ⇒ Object
character-reputation.xml.
-
#character_skills(elem) ⇒ Object
character-skills.xml.
- #character_tab(elem) ⇒ Object
-
#initialize(sheet, skills, reputation, api = nil) ⇒ FullCharacter
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, skills, reputation, api = nil) ⇒ FullCharacter
It’s made up of two parts Don’t care about battlegroups yet I don’t think I can call stuff from the constructor?
164 165 166 167 168 169 170 171 |
# File 'lib/wowr/character.rb', line 164 def initialize(sheet, skills, reputation, api = nil) @api = api character_info(sheet%'character') character_tab(sheet%'characterTab') character_skills(skills) character_reputation(reputation) 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
134 135 136 |
# File 'lib/wowr/character.rb', line 134 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
134 135 136 |
# File 'lib/wowr/character.rb', line 134 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
134 135 136 |
# File 'lib/wowr/character.rb', line 134 def faction @faction end |
#faction_id ⇒ Object (readonly)
character_info
134 135 136 |
# File 'lib/wowr/character.rb', line 134 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 |
#last_modified ⇒ Object (readonly)
character_info
134 135 136 |
# File 'lib/wowr/character.rb', line 134 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 |
#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 |
#reputation_categories ⇒ Object (readonly) Also known as: rep, reputation
Returns the value of attribute reputation_categories.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def reputation_categories @reputation_categories 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 |
#skill_categories ⇒ Object (readonly) Also known as: skills
Returns the value of attribute skill_categories.
148 149 150 |
# File 'lib/wowr/character.rb', line 148 def skill_categories @skill_categories 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
134 135 136 |
# File 'lib/wowr/character.rb', line 134 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=""
race="Orc"
raceId="2"
realm="Genjuros"
suffix=""/>
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 237 |
# File 'lib/wowr/character.rb', line 192 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] @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_reputation(elem) ⇒ Object
character-reputation.xml
304 305 306 307 308 309 |
# File 'lib/wowr/character.rb', line 304 def character_reputation(elem) @reputation_categories = {} (elem/:factionCategory).each do |category| @reputation_categories[category[:key]] = RepFactionCategory.new(category) end end |
#character_skills(elem) ⇒ Object
character-skills.xml
296 297 298 299 300 301 |
# File 'lib/wowr/character.rb', line 296 def character_skills(elem) @skill_categories = {} (elem/:skillCategory).each do |category| @skill_categories[category[:key]] = SkillCategory.new(category) end end |
#character_tab(elem) ⇒ Object
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 |
# File 'lib/wowr/character.rb', line 239 def character_tab(elem) # <title value=""/> @title = (elem%'title')[:value] == "" ? nil : (elem%'title')[:value] #@known_titles = <knownTitles/> @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') # Also accessible from # character.skills['professions'] @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 |