Class: RsApi::PlayerExperience
- Defined in:
- lib/rs_api/hiscores/player_experience.rb
Overview
Class PlayerExp pulls, from Hiscores, player level/experience in each skill.
Constant Summary
Constants included from SkillHelper
SkillHelper::MAX, SkillHelper::MONTHLY_XP_SKILL_ID_CONST, SkillHelper::SKILL_ID_CONST
Instance Attribute Summary collapse
-
#player_name ⇒ Object
readonly
Returns the value of attribute player_name.
-
#table_results ⇒ Object
readonly
Returns the value of attribute table_results.
Instance Method Summary collapse
- #all_skill_experience ⇒ Object
- #display ⇒ Object
-
#initialize(player_name) ⇒ PlayerExperience
constructor
A new instance of PlayerExperience.
- #max_skill_level ⇒ Object
- #raw_data ⇒ Object
- #skills_at_max_level ⇒ Object
Methods included from PlayerNameHelper
Constructor Details
#initialize(player_name) ⇒ PlayerExperience
Returns a new instance of PlayerExperience.
18 19 20 21 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 18 def initialize(player_name) PlayerNameHelper.check_player_name(player_name) @player_name = player_name end |
Instance Attribute Details
#player_name ⇒ Object (readonly)
Returns the value of attribute player_name.
16 17 18 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 16 def player_name @player_name end |
#table_results ⇒ Object (readonly)
Returns the value of attribute table_results.
16 17 18 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 16 def table_results @table_results end |
Instance Method Details
#all_skill_experience ⇒ Object
52 53 54 55 56 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 52 def all_skill_experience # Retuns array containing the experience for each skill # Index of skills corresponds to RsConst::SKILL_ID_CONST raw_data.map { |n| n.last.delete(',').to_i } end |
#display ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 23 def display fill_table_data if table.rows.empty? if display? # :nocov: colour? ? (puts colour_table) : (puts table) # :nocov: end table rescue RsApi::RsRequest::PlayerNotFound puts "#{@player_name} does not exist.".red if display? end |
#max_skill_level ⇒ Object
39 40 41 42 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 39 def max_skill_level # Returns the highest skill level out of all sklls raw_data[1..].map { |value| value[1].to_i }.max.to_s end |
#raw_data ⇒ Object
35 36 37 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 35 def raw_data @raw_data ||= parsed[0..29] end |
#skills_at_max_level ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rs_api/hiscores/player_experience.rb', line 44 def skills_at_max_level # Returns a array containing only skills at max_skill_level # SKILL_ID_CONST[i+1] | i is +1 because I don't want to load the overall skill totals raw_data[1..].filter_map.with_index do |value, i| SKILL_ID_CONST[i + 1].to_s.capitalize if value[1] == max_skill_level end end |