Class: Wowr::Classes::Character
- Inherits:
-
Object
- Object
- Wowr::Classes::Character
- Defined in:
- lib/wowr/character.rb
Overview
See Also: Guild
Direct Known Subclasses
Constant Summary collapse
- @@race_icon_url_base =
'images/icons/race/'
- @@class_icon_url_base =
'images/icons/class/'
- @@portrait_url_base =
'images/portraits/'
- @@icon_types =
{:default => 'wow-default', 70 => 'wow-70', :other => 'wow'}
Instance Attribute Summary collapse
-
#battle_group ⇒ Object
readonly
Returns the value of attribute battle_group.
-
#contribution ⇒ Object
readonly
Returns the value of attribute contribution.
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#gender_id ⇒ Object
readonly
Returns the value of attribute gender_id.
-
#guild ⇒ Object
readonly
Returns the value of attribute guild.
-
#guild_id ⇒ Object
readonly
Returns the value of attribute guild_id.
-
#guild_url ⇒ Object
readonly
Returns the value of attribute guild_url.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#klass_id ⇒ Object
readonly
Returns the value of attribute klass_id.
-
#last_login ⇒ Object
readonly
Returns the value of attribute last_login.
-
#level ⇒ Object
(also: #to_i)
readonly
Returns the value of attribute level.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
-
#race ⇒ Object
readonly
Returns the value of attribute race.
-
#race_id ⇒ Object
readonly
Returns the value of attribute race_id.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#realm ⇒ Object
readonly
Returns the value of attribute realm.
-
#relevance ⇒ Object
readonly
Returns the value of attribute relevance.
-
#search_rank ⇒ Object
readonly
Returns the value of attribute search_rank.
-
#season_games_played ⇒ Object
readonly
Returns the value of attribute season_games_played.
-
#season_games_won ⇒ Object
readonly
Returns the value of attribute season_games_won.
-
#team_rank ⇒ Object
readonly
Returns the value of attribute team_rank.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #class_icon ⇒ Object
- #icon(type = nil) ⇒ Object
-
#initialize(elem, api = nil) ⇒ Character
constructor
A new instance of Character.
- #race_icon ⇒ Object
Constructor Details
#initialize(elem, api = nil) ⇒ Character
Returns a new instance of Character.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/wowr/character.rb', line 38 def initialize(elem, api = nil) @api = api @name = elem[:name] @level = elem[:level].to_i @url = elem[:url] || elem[:charUrl] @rank = elem[:rank].to_i @klass = elem[:class] @klass_id = elem[:classId].to_i @gender = elem[:gender] @gender_id = elem[:genderId].to_i @race = elem[:race] @race_id = elem[:raceId].to_i @guild = elem[:guild] == "" ? nil : elem[:guild] @guild_id = elem[:guildId].to_i == 0 ? nil : elem[:guildId].to_i @guild_url = elem[:guildUrl] == "" ? nil : elem[:guildUrl] @realm = elem[:realm] == "" ? nil : elem[:realm] @battle_group = elem[:battleGroup] == "" ? nil : elem[:battleGroup] @battle_group_id = elem[:battleGroupId].to_i @relevance = elem[:relevance].to_i @search_rank = elem[:searchRank].to_i # Incoming string is 2007-02-24 20:33:04.0, parse to datetime #@last_login = elem[:lastLoginDate] == "" ? nil : DateTime.parse(elem[:lastLoginDate]) @last_login = elem[:lastLoginDate] == "" ? nil : elem[:lastLoginDate] # From ArenaTeam info, can be blank on normal requests #<character battleGroup="" charUrl="r=Draenor&n=Lothaar" class="Paladin" classId="2" # contribution="1602" gamesPlayed="10" gamesWon="7" gender="Male" genderId="0" # guild="Passion" guildId="36659" guildUrl="r=Draenor&n=Passion&p=1" name="Lothaar" # race="Human" raceId="1" seasonGamesPlayed="20" seasonGamesWon="13" teamRank="1"/> @season_games_played = elem[:seasonGamesPlayed] == "" ? nil : elem[:seasonGamesPlayed].to_i @season_games_won = elem[:seasonGamesWon] == "" ? nil : elem[:seasonGamesWon].to_i @team_rank = elem[:teamRank] == "" ? nil : elem[:teamRank].to_i @contribution = elem[:contribution] == "" ? nil : elem[:contribution].to_i #@char_url = elem[:charUrl] # TODO: Merge with URL? end |
Instance Attribute Details
#battle_group ⇒ Object (readonly)
Returns the value of attribute battle_group.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def battle_group @battle_group end |
#contribution ⇒ Object (readonly)
Returns the value of attribute contribution.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def contribution @contribution end |
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def gender @gender end |
#gender_id ⇒ Object (readonly)
Returns the value of attribute gender_id.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def gender_id @gender_id end |
#guild ⇒ Object (readonly)
Returns the value of attribute guild.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def guild @guild end |
#guild_id ⇒ Object (readonly)
Returns the value of attribute guild_id.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def guild_id @guild_id end |
#guild_url ⇒ Object (readonly)
Returns the value of attribute guild_url.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def guild_url @guild_url end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def klass @klass end |
#klass_id ⇒ Object (readonly)
Returns the value of attribute klass_id.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def klass_id @klass_id end |
#last_login ⇒ Object (readonly)
Returns the value of attribute last_login.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def last_login @last_login end |
#level ⇒ Object (readonly) Also known as: to_i
Returns the value of attribute level.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def level @level end |
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def name @name end |
#race ⇒ Object (readonly)
Returns the value of attribute race.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def race @race end |
#race_id ⇒ Object (readonly)
Returns the value of attribute race_id.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def race_id @race_id end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def rank @rank end |
#realm ⇒ Object (readonly)
Returns the value of attribute realm.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def realm @realm end |
#relevance ⇒ Object (readonly)
Returns the value of attribute relevance.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def relevance @relevance end |
#search_rank ⇒ Object (readonly)
Returns the value of attribute search_rank.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def search_rank @search_rank end |
#season_games_played ⇒ Object (readonly)
Returns the value of attribute season_games_played.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def season_games_played @season_games_played end |
#season_games_won ⇒ Object (readonly)
Returns the value of attribute season_games_won.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def season_games_won @season_games_won end |
#team_rank ⇒ Object (readonly)
Returns the value of attribute team_rank.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def team_rank @team_rank end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
19 20 21 |
# File 'lib/wowr/character.rb', line 19 def url @url end |
Instance Method Details
#class_icon ⇒ Object
108 109 110 111 |
# File 'lib/wowr/character.rb', line 108 def class_icon # http://armory.worldofwarcraft.com/images/icons/class/8.gif return base + @@class_icon_url_base + "#{@klass_id.to_s}.gif" end |
#icon(type = nil) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/wowr/character.rb', line 84 def icon(type = nil) if !type.nil? && !@@icon_types.include?(type) raise Wowr::Exceptions::InvalidIconType.new(@@icon_types) end if (type.nil?) && (@level == 70) dir = @@icon_types[70] elsif (type.nil?) dir = @@icon_types[:other] else dir = @@icon_types[type] end # http://armory.worldofwarcraft.com/images/portraits/wow-70/1-7-8.gif return base + @@portrait_url_base + dir + "/#{@gender_id}-#{@race_id}-#{@klass_id}.gif" end |
#race_icon ⇒ Object
102 103 104 105 |
# File 'lib/wowr/character.rb', line 102 def race_icon # http://armory.worldofwarcraft.com/images/icons/race/11-1.gif return base + @@race_icon_url_base + "#{@race_id}-#{@gender_id.to_s}.gif" end |