Class: Armory::Character::Item
- Inherits:
-
Object
- Object
- Armory::Character::Item
- Defined in:
- lib/armory/character.rb
Instance Attribute Summary collapse
-
#durability ⇒ Object
Returns the value of attribute durability.
-
#enchant_id ⇒ Object
Returns the value of attribute enchant_id.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
-
#id ⇒ Object
Returns the value of attribute id.
-
#level ⇒ Object
Returns the value of attribute level.
-
#max_durability ⇒ Object
Returns the value of attribute max_durability.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rarity ⇒ Object
Returns the value of attribute rarity.
-
#slot ⇒ Object
Returns the value of attribute slot.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize ⇒ Item
Returns a new instance of Item.
58 59 60 |
# File 'lib/armory/character.rb', line 58 def initialize @gems = [] end |
Instance Attribute Details
#durability ⇒ Object
Returns the value of attribute durability.
55 56 57 |
# File 'lib/armory/character.rb', line 55 def durability @durability end |
#enchant_id ⇒ Object
Returns the value of attribute enchant_id.
55 56 57 |
# File 'lib/armory/character.rb', line 55 def enchant_id @enchant_id end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
56 57 58 |
# File 'lib/armory/character.rb', line 56 def gems @gems end |
#id ⇒ Object
Returns the value of attribute id.
54 55 56 |
# File 'lib/armory/character.rb', line 54 def id @id end |
#level ⇒ Object
Returns the value of attribute level.
54 55 56 |
# File 'lib/armory/character.rb', line 54 def level @level end |
#max_durability ⇒ Object
Returns the value of attribute max_durability.
55 56 57 |
# File 'lib/armory/character.rb', line 55 def max_durability @max_durability end |
#name ⇒ Object
Returns the value of attribute name.
54 55 56 |
# File 'lib/armory/character.rb', line 54 def name @name end |
#rarity ⇒ Object
Returns the value of attribute rarity.
54 55 56 |
# File 'lib/armory/character.rb', line 54 def rarity @rarity end |
#slot ⇒ Object
Returns the value of attribute slot.
54 55 56 |
# File 'lib/armory/character.rb', line 54 def slot @slot end |
Class Method Details
.from_armory(doc) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/armory/character.rb', line 62 def self.from_armory(doc) Item.new.tap do |item| item.id = doc.attr('id').to_i item.name = doc.attr('name') item.level = doc.attr('level').to_i item.slot = doc.attr('slot').to_i item.rarity = doc.attr('rarity').to_i item.durability = doc.attr('durability').to_i item.max_durability = doc.attr('maxDurability').to_i item.enchant_id = doc.attr('permanentEnchantItemId').to_i 3.times do |i| gem = doc.attr("gem#{i}Id").to_i item.gems << gem if gem != 0 end end end |