Sha256: 2f7040ac437942bdeb0fc9c6e4d50e6a7affc215634e0a1480a50cc594f235a3

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

module EveOnline
  class Item
    attr_reader :options

    def initialize(options = {})
      @options = options
    end

    def as_json(*args)
      {
        item_id: item_id,
        location_id: location_id,
        type_id: type_id,
        quantity: quantity,
        flag: flag,
        singleton: singleton,
        raw_quantity: raw_quantity
      }
    end

    def item_id
      @item_id ||= options.fetch('@itemID').to_i
    end

    def location_id
      @location_id ||= options.fetch('@locationID').to_i
    end

    def type_id
      @type_id ||= options.fetch('@typeID').to_i
    end

    def quantity
      @quantity ||= options.fetch('@quantity').to_i
    end

    def flag
      @flag ||= options.fetch('@flag').to_i
    end

    def singleton
      @singleton ||= options.fetch('@singleton').to_i
    end

    def raw_quantity
      @raw_quantity ||= options.fetch('@rawQuantity').to_i
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.7.0 lib/eve_online/item.rb