Class: EVEApi::Alliance
- Inherits:
-
Object
- Object
- EVEApi::Alliance
- 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
-
#href ⇒ String
Href.
-
#id ⇒ Fixnum
ID.
-
#id_str ⇒ String
String ID.
-
#info ⇒ Hash
Get detailed Alliance info from CREST.
-
#name ⇒ String
Name.
-
#short_name ⇒ String
Short name.
Instance Method Summary collapse
-
#corporations ⇒ Array
Show corporations belonging to the Alliance.
-
#find ⇒ Alliance
Get Alliance from CREST by ID.
-
#initialize(args) ⇒ Alliance
constructor
A new instance of Alliance.
- #to_h ⇒ Hash
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
#id ⇒ Fixnum
Returns ID.
11 12 13 |
# File 'lib/eveapi/alliance.rb', line 11 def id @id end |
#id_str ⇒ String
Returns String ID.
8 9 10 |
# File 'lib/eveapi/alliance.rb', line 8 def id_str @id_str end |
#info ⇒ Hash
Get detailed Alliance info from CREST
12 13 14 |
# File 'lib/eveapi/alliance.rb', line 12 def info @info end |
#short_name ⇒ String
Returns Short name.
9 10 11 |
# File 'lib/eveapi/alliance.rb', line 9 def short_name @short_name end |
Instance Method Details
#corporations ⇒ Array
Show corporations belonging to the Alliance
37 38 39 |
# File 'lib/eveapi/alliance.rb', line 37 def corporations info[:corporations] end |
#find ⇒ Alliance
Get Alliance from CREST by ID
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_h ⇒ Hash
Converts EVEApi::Alliance to Hash
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 |