Class: Omega::ScoreboardEntry
Instance Attribute Summary collapse
-
#problems ⇒ Object
Returns the value of attribute problems.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Attributes inherited from Base
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(client, entry) ⇒ ScoreboardEntry
constructor
A new instance of ScoreboardEntry.
- #merge(score) ⇒ Object
- #score_for(name) ⇒ Object
- #simple_display ⇒ Object
Constructor Details
#initialize(client, entry) ⇒ ScoreboardEntry
Returns a new instance of ScoreboardEntry.
10 11 12 13 14 15 |
# File 'lib/omega/scoreboard.rb', line 10 def initialize(client, entry) @username = entry[:username] @client = client @problems = entry[:problems] || [] @data = entry end |
Instance Attribute Details
#problems ⇒ Object
Returns the value of attribute problems.
7 8 9 |
# File 'lib/omega/scoreboard.rb', line 7 def problems @problems end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/omega/scoreboard.rb', line 8 def username @username end |
Instance Method Details
#<=>(other) ⇒ Object
31 32 33 |
# File 'lib/omega/scoreboard.rb', line 31 def <=>(other) other.data[:total][:points] <=> @data[:total][:points] end |
#merge(score) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/omega/scoreboard.rb', line 17 def merge(score) result = clone result.problems += score.problems result.data[:total][:points] += score.data[:total][:points] result end |
#score_for(name) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/omega/scoreboard.rb', line 35 def score_for(name) problems.each do |problem| return problem if problem[:alias] == name end nil end |
#simple_display ⇒ Object
24 25 26 27 28 29 |
# File 'lib/omega/scoreboard.rb', line 24 def simple_display { username: @data[:username], score: @data[:total][:points] } end |