Class: EveApi::Api

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

Direct Known Subclasses

ScopedApi

Constant Summary collapse

BASE_URI =
"https://api.eveonline.com"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyID, vCode) ⇒ Api

Returns a new instance of Api.



5
6
7
8
# File 'lib/eve_api/api.rb', line 5

def initialize(keyID, vCode)
  @keyID = keyID
  @vCode = vCode
end

Class Method Details

.canonic_path(path) ⇒ Object



34
35
36
# File 'lib/eve_api/api.rb', line 34

def self.canonic_path(path)
  path.to_s.downcase.split("_").map{ |m| m.capitalize }.reduce(:+)
end

.uri(path, scope) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/eve_api/api.rb', line 38

def self.uri(path, scope)
  scope_uri = Addressable::URI.parse("/#{scope.to_s}/")
  
  path_capitalized = self.canonic_path(path)
  path_capitalized += ".xml.aspx"
  
  path_uri = Addressable::URI.parse(path_capitalized)
  
  final_uri = scope_uri + path_uri
  
  return final_uri
end

Instance Method Details

#accountObject



10
11
12
# File 'lib/eve_api/api.rb', line 10

def 
  ScopedApi.new(@keyID, @vCode, :account)
end

#charObject



14
15
16
# File 'lib/eve_api/api.rb', line 14

def char
  ScopedApi.new(@keyID, @vCode, :char)
end

#corpObject



18
19
20
# File 'lib/eve_api/api.rb', line 18

def corp
  ScopedApi.new(@keyID, @vCode, :corp)
end

#eveObject



22
23
24
# File 'lib/eve_api/api.rb', line 22

def eve
  ScopedApi.new(@keyID, @vCode, :eve)
end

#mapObject



26
27
28
# File 'lib/eve_api/api.rb', line 26

def map
  ScopedApi.new(@keyID, @vCode, :map)
end

#serverObject



30
31
32
# File 'lib/eve_api/api.rb', line 30

def server
  ScopedApi.new(@keyID, @vCode, :map)
end