Class: EveApi::Crest
- Inherits:
-
Object
- Object
- EveApi::Crest
- Defined in:
- lib/eve_api/crest.rb
Constant Summary collapse
- BASE_URI =
"https://public-crest.eveonline.com"
Instance Attribute Summary collapse
-
#cache_only ⇒ Object
Returns the value of attribute cache_only.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #call(opt = {}) ⇒ Object
-
#initialize(path, cache_only = false) ⇒ Crest
constructor
A new instance of Crest.
Constructor Details
#initialize(path, cache_only = false) ⇒ Crest
Returns a new instance of Crest.
7 8 9 10 |
# File 'lib/eve_api/crest.rb', line 7 def initialize(path, cache_only = false) self.path = path self.cache_only = cache_only end |
Instance Attribute Details
#cache_only ⇒ Object
Returns the value of attribute cache_only.
5 6 7 |
# File 'lib/eve_api/crest.rb', line 5 def cache_only @cache_only end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/eve_api/crest.rb', line 5 def path @path end |
Instance Method Details
#call(opt = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eve_api/crest.rb', line 12 def call(opt = {}) splat = render(opt) conn = Faraday.new(:url => BASE_URI) do |faraday| faraday.request :url_encoded faraday.adapter Faraday.default_adapter end response = conn.get("/#{splat.join('/')}/") case response.status when 200 return JSON.parse(response.body) when 404 raise EAAL::Exception::APINotFoundError.new("The requested API (#{splat}) could not be found.") else raise EAAL::Exception::HTTPError.new("An HTTP Error occured, body: " + response.body) end end |