lib/clock.rb in danno_ball_clock-0.0.2 vs lib/clock.rb in danno_ball_clock-0.0.3

- old
+ new

@@ -6,11 +6,12 @@ # @class Clock # Useage: `ruby -Ilib ./bin/clock {27,0}` or `ruby -Ilib ./bin/clock {30,325}` ### class Clock ### - # @method add_minute adds a ball from the begining of the main + # @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 @@ -48,11 +49,11 @@ end ### # @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 it will calculate the days tell the que repeats. + # is provided it will calculate the days tell the que repeats. ### def self.run_ball_clock(balls, run_time) @current_que = [] @hours_passed = '0'.to_i @repeat = false @@ -68,16 +69,15 @@ end if run_time.to_i == 0 || nil until @repeat == true add_minute end - result = puts "Clock cycles in: #{@cycle_days} day\(s\)\." + "Clock cycles in: #{@cycle_days} day\(s\)\." else until min_left == 0 add_minute min_left -= 1 end - json_clock = { min: @min_track, fiveMin: @five_min_track, hour: @hour_track, main: @current_que } + JSON.generate(min: @min_track, fiveMin: @five_min_track, hour: @hour_track, main: @current_que) end - JSON.generate(json_clock) end end