Sha256: a378d2483e320d1fdd40781f21f1552838d771651ade10e68411758e747a91ca

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

class MWO::Mech < OpenStruct
  extend MWO::Utils

  # def initialize args = {}
  #   args.each do |k,v|
  #     instance_variable_set("@#{k}", v) unless v.nil?
  #   end
  # end

  def self.all
    client = MWO::Client.new(overrides: {})
    raw = fetch(client.mechs_url)

    mechs = []
    raw["Mechs"].each do |name, attrs|

      # Remove the loadout from the index.
      attrs.delete('Loadout')

      # 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

      mechs << new(mech)
    end
    mechs
  end

  def self.dictionary
    client = MWO::Client.new(overrides: {})
    raw = fetch(client.mech_ids_url)
    raw["Mechs"]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mwo-0.1.0 lib/mwo/mech.rb