class EVEApi::Crest

CREST API handling

Attributes

connection[RW]

Public Class Methods

new() click to toggle source
# File lib/eveapi/crest.rb, line 5
def initialize
  @connection ||= Excon.new(CREST_ENDPOINT)
end

Public Instance Methods

alliances() click to toggle source

List of Alliances

@return [Array] Array of {Alliance} objects @see Alliance

# File lib/eveapi/crest.rb, line 23
def alliances
  alliances = paginate(__method__.to_s + '/')
  alliances.map do |alliance|
    EVEApi::Alliance.new alliance[:href]
  end
end
types() click to toggle source

List of Types

@return [Array] List of types with descriptions and ID’s

# File lib/eveapi/crest.rb, line 33
def types
  types = paginate(__method__.to_s + '/')
  types.map do |type|
    type.merge!(type_id: type[:href].match(%r{(\d*)\/$})[1])
  end
end

Private Instance Methods

paginate(path) click to toggle source
# File lib/eveapi/crest.rb, line 9
def paginate(path)
  output = json_get(CREST_ENDPOINT, path: path)
  2.upto(output[:page_count]) do |i|
    new_request = json_get(CREST_ENDPOINT, path: path, query: { page: i })
    output[:items].concat(new_request[:items])
  end
  output[:items]
end