Class: Wowr::Classes::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/wowr/classes.rb

Overview

Short character info, used in guild lists etc. Note that the way that searches and character listings within guilds works, there can be a variable amount of information filled in within the class. Guild listings and search results contain a smaller amount of information than single queries

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elem) ⇒ Character

Returns a new instance of Character.



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
82
83
84
85
# File 'lib/wowr/classes.rb', line 46

def initialize(elem)
	@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]
	
	@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&amp;n=Lothaar" class="Paladin" classId="2"
	# contribution="1602" gamesPlayed="10" gamesWon="7" gender="Male" genderId="0"
	# guild="Passion" guildId="36659" guildUrl="r=Draenor&amp;n=Passion&amp;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_groupObject (readonly)

Returns the value of attribute battle_group.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def battle_group
  @battle_group
end

#contributionObject (readonly)

Returns the value of attribute contribution.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def contribution
  @contribution
end

#genderObject (readonly)

Returns the value of attribute gender.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def gender
  @gender
end

#gender_idObject (readonly)

Returns the value of attribute gender_id.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def gender_id
  @gender_id
end

#guildObject (readonly)

Returns the value of attribute guild.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def guild
  @guild
end

#guild_idObject (readonly)

Returns the value of attribute guild_id.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def guild_id
  @guild_id
end

#guild_urlObject (readonly)

Returns the value of attribute guild_url.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def guild_url
  @guild_url
end

#klassObject (readonly)

Returns the value of attribute klass.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def klass
  @klass
end

#klass_idObject (readonly)

Returns the value of attribute klass_id.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def klass_id
  @klass_id
end

#last_loginObject (readonly)

Returns the value of attribute last_login.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def 
  @last_login
end

#levelObject (readonly)

Returns the value of attribute level.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def level
  @level
end

#nameObject (readonly)

Returns the value of attribute name.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def name
  @name
end

#raceObject (readonly)

Returns the value of attribute race.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def race
  @race
end

#race_idObject (readonly)

Returns the value of attribute race_id.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def race_id
  @race_id
end

#rankObject (readonly)

Returns the value of attribute rank.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def rank
  @rank
end

#relevanceObject (readonly)

Returns the value of attribute relevance.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def relevance
  @relevance
end

#search_rankObject (readonly)

Returns the value of attribute search_rank.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def search_rank
  @search_rank
end

#season_games_playedObject (readonly)

Returns the value of attribute season_games_played.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def season_games_played
  @season_games_played
end

#season_games_wonObject (readonly)

Returns the value of attribute season_games_won.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def season_games_won
  @season_games_won
end

#team_rankObject (readonly)

Returns the value of attribute team_rank.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def team_rank
  @team_rank
end

#urlObject (readonly)

Returns the value of attribute url.



36
37
38
# File 'lib/wowr/classes.rb', line 36

def url
  @url
end