Class: Smite::Item
Instance Attribute Summary
Attributes inherited from Object
#data
Instance Method Summary
collapse
Methods inherited from Object
#attributes, #method_missing
Constructor Details
#initialize(data) ⇒ Item
Returns a new instance of Item.
4
5
6
7
8
9
10
11
|
# File 'lib/smite/item.rb', line 4
def initialize(data)
super(data)
effects = @data.delete('item_description')
@data['description'] = effects.delete('Description')
@data['effects'] = effects['Menuitems'].map do |eff|
ItemEffect.new(device_name, eff)
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Smite::Object
Instance Method Details
#active? ⇒ Boolean
13
14
15
|
# File 'lib/smite/item.rb', line 13
def active?
type == 'Active'
end
|
#consumable? ⇒ Boolean
17
18
19
|
# File 'lib/smite/item.rb', line 17
def consumable?
type == 'Consumable'
end
|
45
46
47
|
# File 'lib/smite/item.rb', line 45
def inspect
"#<Smite::Item #{item_id} '#{device_name}'>"
end
|
#item? ⇒ Boolean
21
22
23
|
# File 'lib/smite/item.rb', line 21
def item?
type == 'Item'
end
|
#magic? ⇒ Boolean
39
40
41
42
43
|
# File 'lib/smite/item.rb', line 39
def magic?
@magic ||= !effects.map(&:attribute).any? do |eff|
eff =~ /physical_(power|pen)/
end
end
|
29
30
31
|
# File 'lib/smite/item.rb', line 29
def name
device_name
end
|
#physical? ⇒ Boolean
33
34
35
36
37
|
# File 'lib/smite/item.rb', line 33
def physical?
@physical ||= !effects.map(&:attribute).any? do |eff|
eff =~ /magic(al)?_(power|pen)/
end
end
|
#starter? ⇒ Boolean
25
26
27
|
# File 'lib/smite/item.rb', line 25
def starter?
starting_item
end
|