Sha256: 81de108bfb211409481a2c2d7fdc75e2e00498086dbe3229cd920e34e9792ecc

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

require 'active_support/time'

module EveOnline
  class MarketOrder
    attr_reader :options

    def initialize(options)
      @options = options
    end

    def as_json
      {
        order_id: order_id,
        char_id: char_id,
        station_id: station_id,
        vol_entered: vol_entered,
        vol_remaining: vol_remaining,
        min_volume: min_volume,
        order_state: order_state,
        type_id: type_id,
        range: range,
        account_key: account_key,
        duration: duration,
        escrow: escrow,
        price: price,
        bid: bid,
        issued: issued
      }
    end

    def order_id
      options.fetch('@orderID').to_i
    end

    def char_id
      options.fetch('@charID').to_i
    end

    def station_id
      options.fetch('@stationID').to_i
    end

    def vol_entered
      options.fetch('@volEntered').to_i
    end

    def vol_remaining
      options.fetch('@volRemaining').to_i
    end

    def min_volume
      options.fetch('@minVolume').to_i
    end

    def order_state
      options.fetch('@orderState').to_i
    end

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

    def range
      options.fetch('@range').to_i
    end

    def account_key
      options.fetch('@accountKey').to_i
    end

    def duration
      options.fetch('@duration').to_i
    end

    def escrow
      options.fetch('@escrow').to_f
    end

    def price
      options.fetch('@price').to_f
    end

    def bid
      options.fetch('@bid') == '1'
    end

    def issued
      ActiveSupport::TimeZone['UTC'].parse(options.fetch('@issued'))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eve_online-0.14.0 lib/eve_online/market_order.rb
eve_online-0.13.0 lib/eve_online/market_order.rb
eve_online-0.12.0 lib/eve_online/market_order.rb
eve_online-0.11.0 lib/eve_online/market_order.rb
eve_online-0.10.0 lib/eve_online/market_order.rb
eve_online-0.9.0 lib/eve_online/market_order.rb