lib/clock.rb in danno_ball_clock-0.0.0 vs lib/clock.rb in danno_ball_clock-0.0.1
- old
+ new
@@ -1,14 +1,23 @@
# encoding: utf-8
require 'json'
###
# @author Dan Oberg <dan@cs1.com>
+# @licence MIT
# @class Clock
+# Useage: `ruby -Ilib ./bin/clock {27,0}` or `ruby -Ilib ./bin/clock {30,325}`
###
class Clock
###
- # @method add_minute
+ # @method add_minute adds a ball from the begining of the main
+ # queue to the minute track. Once the minute track is full
+ # the ball will drop to the five minute track triggering in
+ # reverse order the minute track to deposit to the main queue.
+ # When the five minute track is full it will pass the next ball from
+ # from the main queue to the hour track which triggers the five min
+ # track to drop its balls in reverse order to the main queue. When
+ # hour track is full will drop balls in reverse order to the main queue.
###
def self.add_minute
if @min_track.length < 4
@min_track << @current_que.shift
elsif @five_min_track.length < 11
@@ -43,19 +52,14 @@
end
end
end
###
- # @param [Fixnum, Fixnum] runs clock with number of balls and optionally a runtime.
+ # @param [Fixnum, Fixnum] runs clock with number of balls to start with and optionally a runtime.
# @return [Json] json hash for min, five_min, hour and main queues. If no runtime
# is provided will calculate days tell que repeats.
###
def self.run_ball_clock(balls, run_time)
- @min = []
- @five_min = []
- @hour = []
- @main = []
- @result = []
@current_que = []
@hours_passed = '0'.to_i
@repeat = false
min_left = run_time.to_i
@start_order = Array.new(balls.to_i) { |i| i + 1 }