Class: Armory::Character
- Inherits:
-
Object
- Object
- Armory::Character
- Defined in:
- lib/armory/character.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#battle_group ⇒ Object
Returns the value of attribute battle_group.
-
#class_id ⇒ Object
Returns the value of attribute class_id.
-
#faction_id ⇒ Object
Returns the value of attribute faction_id.
-
#gender_id ⇒ Object
Returns the value of attribute gender_id.
-
#guild ⇒ Object
Returns the value of attribute guild.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#level ⇒ Object
Returns the value of attribute level.
-
#name ⇒ Object
Returns the value of attribute name.
-
#race_id ⇒ Object
Returns the value of attribute race_id.
-
#realm ⇒ Object
Returns the value of attribute realm.
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #faction ⇒ Object
- #gender ⇒ Object
-
#initialize ⇒ Character
constructor
A new instance of Character.
- #race ⇒ Object
Constructor Details
#initialize ⇒ Character
Returns a new instance of Character.
10 11 12 |
# File 'lib/armory/character.rb', line 10 def initialize @items = [] end |
Instance Attribute Details
#battle_group ⇒ Object
Returns the value of attribute battle_group.
6 7 8 |
# File 'lib/armory/character.rb', line 6 def battle_group @battle_group end |
#class_id ⇒ Object
Returns the value of attribute class_id.
7 8 9 |
# File 'lib/armory/character.rb', line 7 def class_id @class_id end |
#faction_id ⇒ Object
Returns the value of attribute faction_id.
7 8 9 |
# File 'lib/armory/character.rb', line 7 def faction_id @faction_id end |
#gender_id ⇒ Object
Returns the value of attribute gender_id.
7 8 9 |
# File 'lib/armory/character.rb', line 7 def gender_id @gender_id end |
#guild ⇒ Object
Returns the value of attribute guild.
6 7 8 |
# File 'lib/armory/character.rb', line 6 def guild @guild end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
8 9 10 |
# File 'lib/armory/character.rb', line 8 def items @items end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
6 7 8 |
# File 'lib/armory/character.rb', line 6 def last_modified @last_modified end |
#level ⇒ Object
Returns the value of attribute level.
6 7 8 |
# File 'lib/armory/character.rb', line 6 def level @level end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/armory/character.rb', line 6 def name @name end |
#race_id ⇒ Object
Returns the value of attribute race_id.
7 8 9 |
# File 'lib/armory/character.rb', line 7 def race_id @race_id end |
#realm ⇒ Object
Returns the value of attribute realm.
6 7 8 |
# File 'lib/armory/character.rb', line 6 def realm @realm end |
Class Method Details
.from_armory(doc) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/armory/character.rb', line 30 def self.from_armory(doc) Character.new.tap do |char| info = doc.css("characterInfo character").first char.name = info.attr("name") char.level = info.attr("level").to_i char.guild = info.attr("guildName") char.realm = info.attr("realm") char.battle_group = info.attr("battleGroup") char.last_modified = Date.parse(info.attr('lastModified')) # Attribute ids char.race_id = info.attr("raceId").to_i char.class_id = info.attr("classId").to_i char.gender_id = info.attr("genderId").to_i char.faction_id = info.attr("factionId").to_i doc.css("characterTab items item").each do |item| char.items << Item.from_armory(item) end end end |
Instance Method Details
#class_name ⇒ Object
14 15 16 |
# File 'lib/armory/character.rb', line 14 def class_name Armory::Classes[class_id] end |
#faction ⇒ Object
26 27 28 |
# File 'lib/armory/character.rb', line 26 def faction Armory::Factions[faction_id] end |