Class: Swint::Result
- Inherits:
-
Object
- Object
- Swint::Result
- Defined in:
- lib/swint/result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#end ⇒ Object
Returns the value of attribute end.
-
#rounds ⇒ Object
Returns the value of attribute rounds.
-
#start ⇒ Object
Returns the value of attribute start.
-
#winner ⇒ Object
Returns the value of attribute winner.
Instance Method Summary collapse
-
#initialize(robots) ⇒ Result
constructor
A new instance of Result.
- #step(robot, time) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize(robots) ⇒ Result
Returns a new instance of Result.
13 14 15 16 17 18 19 20 21 |
# File 'lib/swint/result.rb', line 13 def initialize(robots) @data = Hash.new @winner = '<no winner>' robots.each do |k, r| @data[k] = Hash.new @data[k][:robot] = r @data[k][:times] = [] end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/swint/result.rb', line 11 def data @data end |
#end ⇒ Object
Returns the value of attribute end.
10 11 12 |
# File 'lib/swint/result.rb', line 10 def end @end end |
#rounds ⇒ Object
Returns the value of attribute rounds.
10 11 12 |
# File 'lib/swint/result.rb', line 10 def rounds @rounds end |
#start ⇒ Object
Returns the value of attribute start.
10 11 12 |
# File 'lib/swint/result.rb', line 10 def start @start end |
#winner ⇒ Object
Returns the value of attribute winner.
10 11 12 |
# File 'lib/swint/result.rb', line 10 def winner @winner end |
Instance Method Details
#step(robot, time) ⇒ Object
23 24 25 |
# File 'lib/swint/result.rb', line 23 def step(robot, time) @data[robot][:times] << time end |
#time ⇒ Object
27 28 29 |
# File 'lib/swint/result.rb', line 27 def time @end.to_f - @start.to_f end |