Class: Smite::ItemEffect
- Inherits:
-
Object
- Object
- Smite::ItemEffect
- Defined in:
- lib/smite/item_effect.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#device_name ⇒ Object
readonly
Returns the value of attribute device_name.
-
#percentage ⇒ Object
Returns the value of attribute percentage.
Instance Method Summary collapse
-
#initialize(item, data = {}) ⇒ ItemEffect
constructor
A new instance of ItemEffect.
- #inspect ⇒ Object
- #percentage? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(item, data = {}) ⇒ ItemEffect
Returns a new instance of ItemEffect.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/smite/item_effect.rb', line 6 def initialize(item, data = {}) @device_name = item return if data.empty? effect = data.delete('Description').tr(' ','') effect = ActiveSupport::Inflector.underscore(effect) @attribute = effect @attribute = 'magic_protection' if effect == 'magical_protection' @attribute = 'magical_power' if effect == 'magic_power' value = data.delete('Value') @percentage = value[/%/] value = value.tr('+', '').to_f @amount = value end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
3 4 5 |
# File 'lib/smite/item_effect.rb', line 3 def amount @amount end |
#attribute ⇒ Object
Returns the value of attribute attribute.
3 4 5 |
# File 'lib/smite/item_effect.rb', line 3 def attribute @attribute end |
#device_name ⇒ Object (readonly)
Returns the value of attribute device_name.
4 5 6 |
# File 'lib/smite/item_effect.rb', line 4 def device_name @device_name end |
#percentage ⇒ Object
Returns the value of attribute percentage.
3 4 5 |
# File 'lib/smite/item_effect.rb', line 3 def percentage @percentage end |
Instance Method Details
#inspect ⇒ Object
32 33 34 |
# File 'lib/smite/item_effect.rb', line 32 def inspect "#<Smite::ItemEffect '#{device_name}' #{attribute} +#{amount}#{percentage}>" end |
#percentage? ⇒ Boolean
24 25 26 |
# File 'lib/smite/item_effect.rb', line 24 def percentage? !percentage.nil? end |
#to_h ⇒ Object
28 29 30 |
# File 'lib/smite/item_effect.rb', line 28 def to_h { attribute => { amount: amount, percentage: percentage? } } end |