Class: SC2Cli::Subcommands::LadderShared::LadderDetailsTeamMember
- Inherits:
-
Object
- Object
- SC2Cli::Subcommands::LadderShared::LadderDetailsTeamMember
- Defined in:
- lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb
Constant Summary collapse
- @@console =
Shared::Console.instance
- @@race_colour_default =
247
- @@race_colour =
{ "protoss" => 220, "random" => 76, "terran" => 39, "zerg" => 99 }
Instance Attribute Summary collapse
-
#clan ⇒ Object
readonly
Returns the value of attribute clan.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#race ⇒ Object
readonly
Returns the value of attribute race.
Instance Method Summary collapse
-
#initialize(json:) ⇒ LadderDetailsTeamMember
constructor
A new instance of LadderDetailsTeamMember.
- #name_with_clan ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(json:) ⇒ LadderDetailsTeamMember
Returns a new instance of LadderDetailsTeamMember.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 41 def initialize(json:) @@console.fatal("Failed to get ladder team member details: ID missing!") unless json.key?("id") id = json["id"] id = id.to_i if id.kind_of?(String) @@console.fatal("Failed to get ladder team member details: ID is not an integer!") unless id.kind_of?(Integer) @@console.fatal("Failed to get ladder team member details: ID is not valid!") unless id > 0 clan = "None" name = "Unknown" race = "Unknown" if json.key?("clanTag") then if json["clanTag"].kind_of?(String) clan = json["clanTag"] unless json["clanTag"].empty? end end if json.key?("displayName") then if json["displayName"].kind_of?(String) name = json["displayName"] unless json["displayName"].empty? end end if json.key?("favoriteRace") then if json["favoriteRace"].kind_of?(String) race = json["favoriteRace"] unless json["favoriteRace"].empty? end end @clan = clan @id = id @name = name @race = race end |
Instance Attribute Details
#clan ⇒ Object (readonly)
Returns the value of attribute clan.
34 35 36 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 34 def clan @clan end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 35 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
36 37 38 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 36 def name @name end |
#race ⇒ Object (readonly)
Returns the value of attribute race.
37 38 39 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 37 def race @race end |
Instance Method Details
#name_with_clan ⇒ Object
81 82 83 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 81 def name_with_clan result = clan == "None" ? name : "[#{clan}]#{name}" end |
#to_s ⇒ Object
87 88 89 90 91 92 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb', line 87 def to_s colour = @@race_colour.key?(race) ? @@race_colour[race] : @@race_colour_default race = "%-10.10s" % @race result = "#{@@console.format(colour: colour, message: race)}#{name_with_clan}\n" return result end |