Sha256: 5db2189c4bb8b86dd21a8f941fd774f02ee6a2bd12a252c7c859286a69cf1293

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

require 'httparty'

module Eve

  class Base 
    include HTTParty
    base_uri 'https://api.eveonline.com'

    VALID_KEYS = [:characterID, :keyID, :vCode]

    def load_config
      config = {}

      begin
        config = YAML.load(File.read(File.expand_path('~/.eve-api')))
      rescue Errno::ENOENT
        raise "No ~/.eve-api config. The skill queue monitor can't start..." 
      rescue Psych::SyntaxError
        raise "Invalid syntax in ~/.eve-api. The skill queue monitor can't start..." 
      end

      config
    end

    def configure
      config = load_config
      query  = {}

      config.each do |k,v| 
        query[k.to_sym] = v if VALID_KEYS.include? k.to_sym
      end

      query
    end

    def query
      @query ||= configure
    end

    def parse_date(eve_date)
      DateTime.strptime(eve_date, '%Y-%m-%d %H:%M:%S') rescue nil
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blinkenstein-0.2.4 lib/eve/base.rb
blinkenstein-0.2.3 lib/eve/base.rb
blinkenstein-0.2.2 lib/eve/base.rb
blinkenstein-0.2.1 lib/eve/base.rb