Class: Swint::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/swint/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/swint/result.rb', line 11

def data
  @data
end

#endObject

Returns the value of attribute end.



10
11
12
# File 'lib/swint/result.rb', line 10

def end
  @end
end

#roundsObject

Returns the value of attribute rounds.



10
11
12
# File 'lib/swint/result.rb', line 10

def rounds
  @rounds
end

#startObject

Returns the value of attribute start.



10
11
12
# File 'lib/swint/result.rb', line 10

def start
  @start
end

#winnerObject

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

#timeObject



27
28
29
# File 'lib/swint/result.rb', line 27

def time
	@end.to_f - @start.to_f
end