Class: Bnet::WOW::Character
- Inherits:
-
BnetResource
- Object
- BnetResource
- Bnet::WOW::Character
- Defined in:
- lib/bnet/wow/character.rb
Constant Summary
Constants inherited from BnetResource
Instance Attribute Summary collapse
-
#achievement_points ⇒ Object
Returns the value of attribute achievement_points.
-
#battlegroup ⇒ Object
Returns the value of attribute battlegroup.
-
#calc_class ⇒ Object
Returns the value of attribute calc_class.
-
#class ⇒ Object
Returns the value of attribute class.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#level ⇒ Object
Returns the value of attribute level.
-
#name ⇒ Object
Returns the value of attribute name.
-
#race ⇒ Object
Returns the value of attribute race.
-
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
-
#realm ⇒ Object
Returns the value of attribute realm.
-
#region ⇒ Object
Returns the value of attribute region.
-
#total_honorable_kills ⇒ Object
Returns the value of attribute total_honorable_kills.
Class Method Summary collapse
-
.find(args) ⇒ Object
Query Battlenet API for the character profile.
- .from_api(raw_response) ⇒ Object
Instance Method Summary collapse
- #achievements ⇒ Object
- #appearance ⇒ Object
- #audit ⇒ Object
- #feed ⇒ Object
- #guild ⇒ Object
- #hunter_pets ⇒ Object
- #items ⇒ Object
- #mounts ⇒ Object
- #pet_slots ⇒ Object
- #pets ⇒ Object
- #progression ⇒ Object
- #pvp ⇒ Object
- #quests ⇒ Object
- #reputation ⇒ Object
- #stats ⇒ Object
- #talents ⇒ Object
Methods inherited from BnetResource
Constructor Details
This class inherits a constructor from Bnet::BnetResource
Instance Attribute Details
#achievement_points ⇒ Object
Returns the value of attribute achievement_points.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def achievement_points @achievement_points end |
#battlegroup ⇒ Object
Returns the value of attribute battlegroup.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def battlegroup @battlegroup end |
#calc_class ⇒ Object
Returns the value of attribute calc_class.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def calc_class @calc_class end |
#class ⇒ Object
Returns the value of attribute class.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def class @class end |
#gender ⇒ Object
Returns the value of attribute gender.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def gender @gender end |
#level ⇒ Object
Returns the value of attribute level.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def level @level end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def name @name end |
#race ⇒ Object
Returns the value of attribute race.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def race @race end |
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def raw_attributes @raw_attributes end |
#realm ⇒ Object
Returns the value of attribute realm.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def realm @realm end |
#region ⇒ Object
Returns the value of attribute region.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def region @region end |
#total_honorable_kills ⇒ Object
Returns the value of attribute total_honorable_kills.
3 4 5 |
# File 'lib/bnet/wow/character.rb', line 3 def total_honorable_kills @total_honorable_kills end |
Class Method Details
.find(args) ⇒ Object
Query Battlenet API for the character profile
Hash Params:
Required
:region - (e.g. 'us', 'ea')
:name - String name of the toon
:realm - String name of the server the character is on (String)
Optional
:locale - String locale (defaults to 'en_US')
:api_key - String api key
Example : IF a character named ‘AlexeiStukov’ is on ‘DragonMaw’ ‘US’ server
Bnet::WOW::Character.find(region: 'us', name: 'AlexeiStukov', realm: 'Dragonmaw')
Returns a Character with the following attributes
:name, :realm, :battlegroup, :class, :race, :gender, :level,
:achievement_points, :total_honorable_kills, :calc_class
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bnet/wow/character.rb', line 26 def self.find args region = args[:region] realm = args[:realm] name = args[:name] locale = args[:locale] || 'en_US' api_key = args[:api_key] || Bnet.configuration.api_key client = Bnet::WOW.new(region: region) call_url = client.url + "character/#{realm}/#{name}?locale=#{locale}&apikey=#{api_key}" begin data = open(call_url) raw_response = JSON.parse(data.read) if data.status == ['200', 'OK'] && raw_response["code"] != 'NOTFOUND' bnet_object = from_api(raw_response) bnet_object.region = region else bnet_object = nil end rescue OpenURI::HTTPError => e bnet_object = nil end return bnet_object end |
.from_api(raw_response) ⇒ Object
54 55 56 57 58 |
# File 'lib/bnet/wow/character.rb', line 54 def self.from_api(raw_response) character = super(raw_response) character.raw_attributes = raw_response character end |
Instance Method Details
#achievements ⇒ Object
69 70 71 72 73 |
# File 'lib/bnet/wow/character.rb', line 69 def achievements return @achievements if @achievements client = Bnet::WOW.new(region: region) @achievements = client.scoped('achievements', realm: realm, name: name) end |
#appearance ⇒ Object
75 76 77 78 79 |
# File 'lib/bnet/wow/character.rb', line 75 def appearance return @appearance if @appearance client = Bnet::WOW.new(region: region) @appearance = client.scoped('appearance', realm: realm, name: name) end |
#audit ⇒ Object
159 160 161 162 163 |
# File 'lib/bnet/wow/character.rb', line 159 def audit return @audit if @audit client = Bnet::WOW.new(region: region) @audit = client.scoped('audit', realm: realm, name: name) end |
#feed ⇒ Object
81 82 83 84 85 |
# File 'lib/bnet/wow/character.rb', line 81 def feed return @feed if @feed client = Bnet::WOW.new(region: region) @feed = client.scoped('feed', realm: realm, name: name) end |
#guild ⇒ Object
87 88 89 90 91 |
# File 'lib/bnet/wow/character.rb', line 87 def guild return @guild if @guild client = Bnet::WOW.new(region: region) @guild = client.scoped('guild', realm: realm, name: name) end |
#hunter_pets ⇒ Object
93 94 95 96 97 |
# File 'lib/bnet/wow/character.rb', line 93 def hunter_pets return @hunter_pets if @hunter_pets client = Bnet::WOW.new(region: region) @hunter_pets = client.scoped('hunterPets', realm: realm, name: name) end |
#items ⇒ Object
99 100 101 102 103 |
# File 'lib/bnet/wow/character.rb', line 99 def items return @items if @items client = Bnet::WOW.new(region: region) @items = client.scoped('items', realm: realm, name: name) end |
#mounts ⇒ Object
105 106 107 108 109 |
# File 'lib/bnet/wow/character.rb', line 105 def mounts return @mounts if @mounts client = Bnet::WOW.new(region: region) @mounts = client.scoped('mounts', realm: realm, name: name) end |
#pet_slots ⇒ Object
117 118 119 120 121 |
# File 'lib/bnet/wow/character.rb', line 117 def pet_slots return @pet_slots if @pet_slots client = Bnet::WOW.new(region: region) @pet_slots = client.scoped('petSlots', realm: realm, name: name) end |
#pets ⇒ Object
111 112 113 114 115 |
# File 'lib/bnet/wow/character.rb', line 111 def pets return @pets if @pets client = Bnet::WOW.new(region: region) @pets = client.scoped('pets', realm: realm, name: name) end |
#progression ⇒ Object
123 124 125 126 127 |
# File 'lib/bnet/wow/character.rb', line 123 def progression return @progression if @progression client = Bnet::WOW.new(region: region) @progression = client.scoped('progression', realm: realm, name: name) end |
#pvp ⇒ Object
129 130 131 132 133 |
# File 'lib/bnet/wow/character.rb', line 129 def pvp return @pvp if @pvp client = Bnet::WOW.new(region: region) @pvp = client.scoped('pvp', realm: realm, name: name) end |
#quests ⇒ Object
135 136 137 138 139 |
# File 'lib/bnet/wow/character.rb', line 135 def quests return @quests if @quests client = Bnet::WOW.new(region: region) @quests = client.scoped('quests', realm: realm, name: name) end |
#reputation ⇒ Object
141 142 143 144 145 |
# File 'lib/bnet/wow/character.rb', line 141 def reputation return @reputation if @reputation client = Bnet::WOW.new(region: region) @reputation = client.scoped('reputation', realm: realm, name: name) end |