Class: EveOnline::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/eve_online/api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
# File 'lib/eve_online/api/client.rb', line 13

def initialize options = {}
  self.api_base = options[:api_base] || 'http://api.eve-online.com'
  logger = options[:logger] || NullLogger.instance
  self.cache = options[:cache] || FileCache.new(:logger => logger)
  self.logger = logger
end

Instance Method Details

#evaluate_result(row) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/eve_online/api/client.rb', line 55

def evaluate_result row
  container_name = row['name']
  container_name[0] = container_name[0].upcase
  const_defined = EveOnline::Api.const_defined? container_name
  logger.debug "#{const_defined ? 'Found' : 'Unknown'} container: #{container_name}"
  return unless const_defined
  logger.debug "Using container #{container_name}"
  container_class = EveOnline::Api.const_get container_name
  logger.debug "Class instance = #{container_class.inspect}"
  container_class.new row
end

#results_from(xml) ⇒ Object



49
50
51
52
53
# File 'lib/eve_online/api/client.rb', line 49

def results_from xml
  doc = Nokogiri::XML xml
  result = doc.at_xpath '/eveapi/result/rowset'
  evaluate_result result
end

#skill_treeObject



20
21
22
23
# File 'lib/eve_online/api/client.rb', line 20

def skill_tree
  logger.debug "Fetching skill tree"
  results = get '/eve/SkillTree.xml.aspx'
end

#sovereigntyObject



25
26
27
28
# File 'lib/eve_online/api/client.rb', line 25

def sovereignty
  logger.debug "Fetching sovereignty information"
  results = get '/map/Sovereignty.xml.aspx'
end