Sha256: 2b80f7ced65561131f54a918c946d5a97c03ae1258da0669b9a4d4015237dd91

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 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

      attr_reader :key_id, :v_code, :character_id

      def initialize(key_id, v_code, character_id)
        super()
        @key_id = key_id
        @v_code = v_code
        @character_id = character_id
      end

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

      def row
        @row ||= rowset.fetch('row')
      end

      def rowset
        @rowset ||= result.fetch('rowset')
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.7.0 lib/eve_online/characters/blueprints.rb