Class: Eve::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/eve/base.rb

Direct Known Subclasses

SkillQueue

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#configureObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/eve/base.rb', line 25

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

#load_configObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/eve/base.rb', line 11

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

#parse_date(eve_date) ⇒ Object



40
41
42
# File 'lib/eve/base.rb', line 40

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

#queryObject



36
37
38
# File 'lib/eve/base.rb', line 36

def query
  @query ||= configure
end