class SmashRuby::Player
Attributes
country[R]
first_name[R]
full_name[R]
id[R]
last_name[R]
losses[RW]
placement[R]
prefix[R]
tag[R]
Public Class Methods
new(attributes)
click to toggle source
# File lib/smash_ruby/player.rb, line 6 def initialize(attributes) @id = attributes.dig('id') @losses = attributes.dig('losses') @placement = attributes.dig('finalPlacement') build_name(attributes.dig('mutations')) end
Public Instance Methods
full_tag()
click to toggle source
# File lib/smash_ruby/player.rb, line 17 def full_tag prefix.to_s.empty? ? tag : "#{prefix} | #{tag}" end
name_with_tag()
click to toggle source
# File lib/smash_ruby/player.rb, line 21 def name_with_tag "#{first_name} \"#{tag}\" #{last_name}" end
Private Instance Methods
build_name(player_hash)
click to toggle source
# File lib/smash_ruby/player.rb, line 27 def build_name(player_hash) _contact_key, contact_info = player_hash.dig('participants').first _player_key, player_info = player_hash.dig('players').first @first_name = contact_info.dig('contactInfo', 'nameFirst') @last_name = contact_info.dig('contactInfo', 'nameLast') @country = contact_info.dig('contactInfo', 'country') @prefix = player_info.dig('prefix') @tag = player_info.dig('gamerTag') end