Class: XIVLodestone::GearList
- Inherits:
-
Object
- Object
- XIVLodestone::GearList
- Defined in:
- lib/xiv_lodestone/lodestone_character_gear.rb
Overview
A Object that represents a list of Gear pieces The initialiser takes a hash of items in the following layout { :weapon => [“Fist”, 110, “Weapon”, “http://.…”], … }
Defined Under Namespace
Classes: Gear
Instance Method Summary collapse
-
#ilevel ⇒ Object
Calculates the total gear list ilevel Rounds to the nearest whole number like FFXIV ingame calculation returns a #Integer.
-
#initialize(gear_path) ⇒ GearList
constructor
A new instance of GearList.
-
#method_missing(method) ⇒ Object
Generates access methods for each item slot.
-
#to_json ⇒ Object
Returns a JSON string of all items.
Constructor Details
#initialize(gear_path) ⇒ GearList
Returns a new instance of GearList.
13 14 15 16 |
# File 'lib/xiv_lodestone/lodestone_character_gear.rb', line 13 def initialize(gear_path) @items = {} parse_gear(gear_path) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
Generates access methods for each item slot
33 34 35 36 |
# File 'lib/xiv_lodestone/lodestone_character_gear.rb', line 33 def method_missing(method) return @items[method] if @items.key?(method) super end |
Instance Method Details
#ilevel ⇒ Object
Calculates the total gear list ilevel Rounds to the nearest whole number like FFXIV ingame calculation returns a #Integer
20 21 22 23 24 25 26 27 |
# File 'lib/xiv_lodestone/lodestone_character_gear.rb', line 20 def ilevel() ilevel = 0 ilevel = @items[:weapon].ilevel if @items[:shield].nil? @items.each_value do |value| ilevel += value.ilevel unless value.name =~ /Soul of the/i end (ilevel/13).round end |
#to_json ⇒ Object
Returns a JSON string of all items
29 30 31 |
# File 'lib/xiv_lodestone/lodestone_character_gear.rb', line 29 def to_json() @items.to_json end |