Class: MWO::Mech
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- MWO::Mech
- Extended by:
- Utils
- Defined in:
- lib/mwo/mech.rb
Class Method Summary collapse
- .all ⇒ Object
- .all_raw(overrides: {}) ⇒ Object
- .assaults ⇒ Object
- .dictionary ⇒ Object
- .heavies ⇒ Object
- .lights ⇒ Object
- .mediums ⇒ Object
Methods included from Utils
Class Method Details
.all ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mwo/mech.rb', line 9 def self.all mechs = [] all_raw["Mechs"].each do |name, attrs| # Remove the loadout from the index. attrs.delete('Loadout') # The mech classification value is broken in the API attrs.delete('Class') attrs["WeightClass"] = case attrs['MaxTons'] when 0..35 'Light' when 36..55 'Medium' when 56..75 'Heavy' when 76..100 'Assault' when 101.300 'Experimental' end # Remove the 'class' attribute, it is bugged from the API attrs.delete('Loadout') mech = {} attrs.each do |k,v| mech[to_symbol(k)] = v end # set override the invalid classification mechs << new(mech) end return mechs.extend MWO::CollectionUtils end |
.all_raw(overrides: {}) ⇒ Object
4 5 6 7 |
# File 'lib/mwo/mech.rb', line 4 def self.all_raw(overrides: {}) client = MWO::Client.new(overrides: {}) fetch(client.mechs_url) end |
.assaults ⇒ Object
59 60 61 |
# File 'lib/mwo/mech.rb', line 59 def self.assaults all.filter({weight_class: 'Assault'}) end |
.dictionary ⇒ Object
63 64 65 66 67 |
# File 'lib/mwo/mech.rb', line 63 def self.dictionary client = MWO::Client.new(overrides: {}) raw = fetch(client.mech_ids_url) raw["Mechs"] end |
.heavies ⇒ Object
55 56 57 |
# File 'lib/mwo/mech.rb', line 55 def self.heavies all.filter({weight_class: 'Heavy'}) end |
.lights ⇒ Object
47 48 49 |
# File 'lib/mwo/mech.rb', line 47 def self.lights all.filter({weight_class: 'Light'}) end |
.mediums ⇒ Object
51 52 53 |
# File 'lib/mwo/mech.rb', line 51 def self.mediums all.filter({weight_class: 'Medium'}) end |