Class: WarcraftArmory::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/warcraft_armory/character.rb

Overview

Gives you access to Character information

Usage

  • location - A symbol specifying your realm’s location. E.g. :eu or :us

  • realm - A symbol specifying your realm. E.g. :aszune or :bloodhoof

  • character - A symbol specifying the character. E.g. :adries or :dwaria

Available Attributes

  • name - The name of the character

  • prefix - An optional prefix to the name. E.g. “Private ”. Default: “”

  • suffix - An optional suffix to the name. E.g. “ the Explorer”. Default: “”

  • level - The character’s current level. E.g. 48. Note that characters below level 10 are not available on the armory.

  • faction - The name of the character’s faction. E.g. “Alliance” or “Horde”

  • faction_id - The internal (World of Warcraft) id for the faction.

  • race - The name of the character’s race. E.g. “Human” or “Night Elf”

  • race_id - The internal (World of Warcraft) id for the race.

  • class_name - The name of the character’s class. E.g. “Mage” or “Warlock”

  • class_id - The internal (World of Warcraft) id for the class.

  • gender - The character’s gender. E.g. “Male”

  • gender_id - The internal (World of Warcraft) id for gender.

  • points - Total number of the character’s achievement points.

  • last_modifiedat - A DateTime object with the date the armory data was last updated.

  • realm - The official realm name. E.g. “Aszune”

  • battle_group - The battle group for this character. E.g. “Blackout”

  • guild_name - The name of the character’s guild. E.g. “Impact”. Blank is no guild is available.

Available helper methods

  • full_name - Returns the full name of the character, including the prefix and suffix

  • description - Gives the usual World of Warcraft description of the character. E.g. “Level 80 Night Elf Hunter”

Examples

character = WarcraftArmory::Character.find(:eu, :aszune, :adries)
# => <WarcraftArmory::Character>

character.name
# => "Adries"

character.level
# => 48

character.full_name
# => "Adries the Explorer"

characer.description
# => "Level 48 Human Warrior"

Constant Summary collapse

CONFIG =

Load the XML Mappings from the supplied config.yml file.

YAML.load_file("#{GEM_ROOT}/config/config.yml")["character"]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(location, realm, character) ⇒ Object

Finds a World of Warcraft character.

  • location - A symbol specifying your realm’s location. E.g. :eu or :us

  • realm - A symbol specifying your realm. E.g. :aszune or :bloodhoof

  • character - A symbol specifying the character. E.g. :adries or :dwaria

character = WarcraftArmory::Character.find(:eu, :aszune, :adries)
# => <WarcraftArmory::Character>


80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/warcraft_armory/character.rb', line 80

def self.find(location, realm, character)
  result = WarcraftArmory::Character.new
  
  url = WarcraftArmory::Base.generate_url(location, realm, character, CONFIG["file"])
  doc = WarcraftArmory::Utils::Parser.parse_url(url)
        
  CONFIG["attributes"].each_pair do |key, code|
    result.send("#{key}=".to_sym, eval(code))
  end
  
  return result
end

Instance Method Details

#descriptionObject

Returns a classic character description.

characer.description
# => "Level 48 Human Warrior"


69
70
71
# File 'lib/warcraft_armory/character.rb', line 69

def description
  "Level #{level} #{race} #{class_name}"
end

#full_nameObject

Returns the full name of the character, including the prefix and suffix.

character.full_name
# => "Adries the Explorer"


61
62
63
# File 'lib/warcraft_armory/character.rb', line 61

def full_name
  [prefix, name, suffix].join("")
end