Class: Sc2RanksApi::Character
- Inherits:
-
Object
- Object
- Sc2RanksApi::Character
- Defined in:
- lib/sc2ranksapi/character.rb
Instance Attribute Summary collapse
-
#achievement_points ⇒ Object
readonly
Returns the value of attribute achievement_points.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#portrait ⇒ Object
readonly
Returns the value of attribute portrait.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #add_teams(teams_data) ⇒ Object
-
#initialize(data) ⇒ Character
constructor
A new instance of Character.
Constructor Details
#initialize(data) ⇒ Character
Returns a new instance of Character.
7 8 9 10 11 12 13 14 |
# File 'lib/sc2ranksapi/character.rb', line 7 def initialize(data) @achievement_points = data["achievement_points"] @name = data["name"] @region = data["region"] @updated_at = data["updated_at"] add_teams data["teams"] end |
Instance Attribute Details
#achievement_points ⇒ Object (readonly)
Returns the value of attribute achievement_points.
5 6 7 |
# File 'lib/sc2ranksapi/character.rb', line 5 def achievement_points @achievement_points end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sc2ranksapi/character.rb', line 5 def name @name end |
#portrait ⇒ Object (readonly)
Returns the value of attribute portrait.
5 6 7 |
# File 'lib/sc2ranksapi/character.rb', line 5 def portrait @portrait end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
5 6 7 |
# File 'lib/sc2ranksapi/character.rb', line 5 def region @region end |
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
5 6 7 |
# File 'lib/sc2ranksapi/character.rb', line 5 def teams @teams end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/sc2ranksapi/character.rb', line 5 def updated_at @updated_at end |
Instance Method Details
#add_teams(teams_data) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sc2ranksapi/character.rb', line 16 def add_teams(teams_data) @teams = Hash.new if @teams.nil? teams_data.each do |team_data| team = Team.new(team_data) bracket = team_data["bracket"] @teams[bracket] = Array.new if @teams[bracket].nil? @teams[bracket] << team end end |