Class: WoW::CharacterProfile

Inherits:
Base
  • Object
show all
Includes:
HTTParty
Defined in:
lib/wow/features/character_profile.rb

Constant Summary collapse

CLASSES =
{
  1  => :warrior,
  2  => :paladin,
  3  => :hunter,
  4  => :rogue,
  5  => :priest,
  6  => :death_knight,
  7  => :shaman,
  8  => :mage,
  9  => :warlock,
  10 => :monk,
  11 => :druid,
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=

Constructor Details

#initialize(realm, character_name, fields = [], params = {}) ⇒ CharacterProfile

Returns a new instance of CharacterProfile.



20
21
22
23
# File 'lib/wow/features/character_profile.rb', line 20

def initialize(realm, character_name, fields = [], params = {})
  params = params.merge({fields: fields.join(',')})
  super(self.class.data(realm, character_name, params))
end

Class Method Details

.data(realm, character_name, params = {}) ⇒ Object



35
36
37
38
# File 'lib/wow/features/character_profile.rb', line 35

def data(realm, character_name, params = {})
  params.merge!({locale: WoW.locale})
  get("/#{realm}/#{character_name}", query: params).parsed_response
end

Instance Method Details

#lookup(key) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/wow/features/character_profile.rb', line 25

def lookup(key)
  case key
  when :class
    CLASSES[self[key]]
  else
    raise "No lookup mapping for #{key}"
  end
end