Class: WoW::CharacterProfile

Inherits:
Base
  • Object
show all
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.



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

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



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

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

Instance Method Details

#lookup(key) ⇒ Object



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

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