Class: SmashRuby::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/smash_ruby/player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Player

Returns a new instance of Player.



6
7
8
9
10
11
# 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

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def country
  @country
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def first_name
  @first_name
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def full_name
  @full_name
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def id
  @id
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def last_name
  @last_name
end

#lossesObject

Returns the value of attribute losses.



4
5
6
# File 'lib/smash_ruby/player.rb', line 4

def losses
  @losses
end

#placementObject (readonly)

Returns the value of attribute placement.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def placement
  @placement
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def prefix
  @prefix
end

#tagObject (readonly)

Returns the value of attribute tag.



3
4
5
# File 'lib/smash_ruby/player.rb', line 3

def tag
  @tag
end

Instance Method Details

#full_tagObject



17
18
19
# File 'lib/smash_ruby/player.rb', line 17

def full_tag
  prefix.to_s.empty? ? tag : "#{prefix} | #{tag}"
end

#name_with_tagObject



21
22
23
# File 'lib/smash_ruby/player.rb', line 21

def name_with_tag
  "#{first_name} \"#{tag}\" #{last_name}"
end