Class: SC2Cli::Subcommands::LadderShared::LadderDetailsTeam
- Inherits:
-
Object
- Object
- SC2Cli::Subcommands::LadderShared::LadderDetailsTeam
- Defined in:
- lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#joined ⇒ Object
readonly
Returns the value of attribute joined.
-
#losses ⇒ Object
readonly
Returns the value of attribute losses.
-
#members ⇒ Object
readonly
Returns the value of attribute members.
-
#mmr ⇒ Object
readonly
Returns the value of attribute mmr.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
-
#wins ⇒ Object
readonly
Returns the value of attribute wins.
Instance Method Summary collapse
-
#initialize(json:) ⇒ LadderDetailsTeam
constructor
A new instance of LadderDetailsTeam.
- #to_s ⇒ Object
Constructor Details
#initialize(json:) ⇒ LadderDetailsTeam
Returns a new instance of LadderDetailsTeam.
38 39 40 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 78 79 80 81 82 83 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 38 def initialize(json:) joined = 0 losses = 0 members = Array.new mmr = 0 points = 0 previous = 0 wins = 0 if json.key?("joinTimestamp") then joined = json["joinTimestamp"] if json["joinTimestamp"].kind_of?(Integer) end if json.key?("losses") then losses = json["losses"] if json["losses"].kind_of?(Integer) end if json.key?("teamMembers") then members = json["teamMembers"] if json["teamMembers"].kind_of?(Array) end if json.key?("mmr") then mmr = json["mmr"] if json["mmr"].kind_of?(Integer) end if json.key?("points") then points = json["points"] if json["points"].kind_of?(Integer) end if json.key?("previousRank") then previous = json["previousRank"] if json["previousRank"].kind_of?(Integer) end if json.key?("wins") then wins = json["wins"] if json["wins"].kind_of?(Integer) end @members = LadderDetailsTeamMembers.new(json: members) @joined = Time.at(joined) @losses = losses @mmr = mmr @points = points @previous = previous @wins = wins end |
Instance Attribute Details
#joined ⇒ Object (readonly)
Returns the value of attribute joined.
28 29 30 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 28 def joined @joined end |
#losses ⇒ Object (readonly)
Returns the value of attribute losses.
29 30 31 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 29 def losses @losses end |
#members ⇒ Object (readonly)
Returns the value of attribute members.
30 31 32 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 30 def members @members end |
#mmr ⇒ Object (readonly)
Returns the value of attribute mmr.
31 32 33 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 31 def mmr @mmr end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
32 33 34 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 32 def points @points end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
33 34 35 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 33 def previous @previous end |
#wins ⇒ Object (readonly)
Returns the value of attribute wins.
34 35 36 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 34 def wins @wins end |
Instance Method Details
#to_s ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb', line 87 def to_s result = String.new joined = @joined.strftime("%Y-%m-%d %H:%M:%S") result += @members.to_s result += "MMR: #{@mmr.to_s}, Points: #{@points.to_s}, Wins: #{@@console.format(colour: @@colour_wins, message: @wins.to_s)}, Losses: #{@@console.format(colour: @@colour_losses, message: @losses.to_s)}, Joined: #{joined}\n\n" return result end |