Sha256: 66ecbf2ae04cf45dbf868f0ce744585765e71ef49b0d0dbfa794f58f97444c05

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

require 'memoist'

module EveOnline
  module ESI
    class Base
      extend Memoist

      attr_reader :parser

      def initialize
        @parser = JSON
      end

      def url
        raise NotImplementedError
      end

      def user_agent
        "EveOnline API (https://github.com/biow0lf/eve_online) v#{ VERSION }"
      end

      def content
        faraday = Faraday.new

        faraday.headers[:user_agent] = user_agent
        faraday.options.timeout = 60
        faraday.options.open_timeout = 60

        faraday.get(url).body
      rescue Faraday::TimeoutError
        raise EveOnline::Exceptions::TimeoutException
      end
      memoize :content

      def response
        parser.parse(content)
      end
      memoize :response
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.10.0 lib/eve_online/esi/base.rb