Class: Omega::Contest
- Inherits:
-
Base
- Object
- Base
- Omega::Contest
show all
- Defined in:
- lib/omega/contest.rb
Instance Attribute Summary
Attributes inherited from Base
#data
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Constructor Details
This class inherits a constructor from Omega::Base
Instance Method Details
#add_user(user) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/omega/contest.rb', line 11
def add_user(user)
if user.is_a?(String)
@client.add_user_to_contest(user, data[:alias])
else
@client.add_user_to_contest(user.data[:username], data[:alias])
end
end
|
#observe ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/omega/contest.rb', line 19
def observe
last = current = scoreboard
sleep(5)
loop do
current = scoreboard
last.users.each do |score|
puts score.username
current_score = current.score_for(score.username)
score.problems.each do |problem|
name = problem[:alias]
current_problem = current_score.score_for(name)
last_points = problem[:points]
current_points = current_problem[:points]
puts " #{name}::#{last_points} >> #{current_points}"
yield(contest_name, score.username, name, current_points, last_points) if current_points != last_points
end
puts '-' * 60
end
last = current
sleep(15)
end
end
|
#scoreboard ⇒ Object
7
8
9
|
# File 'lib/omega/contest.rb', line 7
def scoreboard
@client.scoreboard(data[:alias])
end
|