Sha256: d2884bc4a70b4d3776c3116a5e3a1957dc58d17f605603ca4393d7efc0139d02

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module EveOnline
  module Characters
    # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_blueprints.html
    class Blueprints < BaseXML
      API_ENDPOINT = 'https://api.eveonline.com/char/Blueprints.xml.aspx'.freeze

      ACCESS_MASK = 2

      attr_reader :key_id, :v_code, :character_id

      def initialize(key_id, v_code, options = {})
        super()
        @key_id = key_id
        @v_code = v_code
        @character_id = options.fetch(:character_id, nil)
      end

      def blueprints
        case row
        when Hash
          [Blueprint.new(row)]
        when Array
          output = []
          row.each do |blueprint|
            output << Blueprint.new(blueprint)
          end
          output
        else
          raise ArgumentError
        end
      end
      memoize :blueprints

      def url
        output = "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }"
        output = "#{ output }&characterID=#{ character_id }" if character_id
        output
      end

      private

      def rowset
        result.fetch('rowset')
      end
      memoize :rowset

      def row
        rowset.fetch('row')
      end
      memoize :row
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eve_online-0.11.0 lib/eve_online/characters/blueprints.rb
eve_online-0.10.0 lib/eve_online/characters/blueprints.rb