Class: SmashRuby::Player
- Inherits:
-
Object
- Object
- SmashRuby::Player
- Defined in:
- lib/smash_ruby/player.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#losses ⇒ Object
Returns the value of attribute losses.
-
#placement ⇒ Object
readonly
Returns the value of attribute placement.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #full_tag ⇒ Object
-
#initialize(attributes) ⇒ Player
constructor
A new instance of Player.
- #name_with_tag ⇒ Object
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
#country ⇒ Object (readonly)
Returns the value of attribute country.
3 4 5 |
# File 'lib/smash_ruby/player.rb', line 3 def country @country end |
#first_name ⇒ Object (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_name ⇒ Object (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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/smash_ruby/player.rb', line 3 def id @id end |
#last_name ⇒ Object (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 |
#losses ⇒ Object
Returns the value of attribute losses.
4 5 6 |
# File 'lib/smash_ruby/player.rb', line 4 def losses @losses end |
#placement ⇒ Object (readonly)
Returns the value of attribute placement.
3 4 5 |
# File 'lib/smash_ruby/player.rb', line 3 def placement @placement end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/smash_ruby/player.rb', line 3 def prefix @prefix end |
#tag ⇒ Object (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_tag ⇒ Object
17 18 19 |
# File 'lib/smash_ruby/player.rb', line 17 def full_tag prefix.to_s.empty? ? tag : "#{prefix} | #{tag}" end |
#name_with_tag ⇒ Object
21 22 23 |
# File 'lib/smash_ruby/player.rb', line 21 def name_with_tag "#{first_name} \"#{tag}\" #{last_name}" end |