Class: EVEApi::Alliance

Inherits:
Object
  • Object
show all
Defined in:
lib/eveapi/alliance.rb

Overview

Alliance CREST object

Constant Summary collapse

BASE_URI =

CREST alliances endpoint

CREST_ENDPOINT + 'alliances/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Alliance

Returns a new instance of Alliance.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/eveapi/alliance.rb', line 14

def initialize(args)
  case args
  when String, Fixnum
    @id = args.to_i
    @href = BASE_URI + id.to_s + '/'
  when Hash
    @href = args[:href]
    @short_name = args[:short_name]
    @name = args[:name]
    @id = args[:id]
  end
end

Instance Attribute Details

#hrefString

Returns href.

Returns:



7
8
9
# File 'lib/eveapi/alliance.rb', line 7

def href
  @href
end

#idFixnum

Returns ID.

Returns:

  • (Fixnum)

    ID



11
12
13
# File 'lib/eveapi/alliance.rb', line 11

def id
  @id
end

#id_strString

Returns String ID.

Returns:



8
9
10
# File 'lib/eveapi/alliance.rb', line 8

def id_str
  @id_str
end

#infoHash

Get detailed Alliance info from CREST

Returns:

  • (Hash)

    Alliance info



12
13
14
# File 'lib/eveapi/alliance.rb', line 12

def info
  @info
end

#nameString

Returns Name.

Returns:



10
11
12
# File 'lib/eveapi/alliance.rb', line 10

def name
  @name
end

#short_nameString

Returns Short name.

Returns:



9
10
11
# File 'lib/eveapi/alliance.rb', line 9

def short_name
  @short_name
end

Instance Method Details

#corporationsArray

Show corporations belonging to the Alliance

Returns:

  • (Array)

    List of corporations



37
38
39
# File 'lib/eveapi/alliance.rb', line 37

def corporations
  info[:corporations]
end

#findAlliance

Get Alliance from CREST by ID

Returns:



44
45
46
47
48
# File 'lib/eveapi/alliance.rb', line 44

def find
  @short_name = info[:short_name]
  @name = info[:name]
  self
end

#to_hHash

Converts EVEApi::Alliance to Hash

Returns:



53
54
55
56
57
58
59
60
61
# File 'lib/eveapi/alliance.rb', line 53

def to_h
  h = {}
  instance_variables.each do |var|
    name = var.to_s.gsub(/^@/, '').to_sym
    value = send name
    h[name] = value
  end
  h
end