danno_ball_clock 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +18 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +19 -0
- data/README.md +6 -3
- data/lib/clock.rb +5 -5
- data/test/test_clock.rb +13 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85435c789cde6ab20f43e5b2bc2a5be4b7c6bd7
|
4
|
+
data.tar.gz: 4821fd02b596d49bdde40d045336379bc518ac68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 447aa427c232fa11b0d5ba80509f58bb60a6499b5e8f278f63fd274b097b93f0f4254731c88d05bbb111c567f31e3f1ae92bb529511eb442a80bda2ca2f5f932
|
7
|
+
data.tar.gz: 312f886e21cdb6b28ea7eed1c8781a52db5a6cc7e52a9883d8aa814a567cd93636be3005c6097e61c5ed413c260ce05e5387edac6ccb7235b89dc1dd8eac9d0d
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
| _ \ / _ \ | \ / \ | | | | / 12 \
|
3
3
|
| | | | | | | | | [] / / ^ \ | | | | | ^ |
|
4
4
|
| |_| | | |_| | | [] \ / /\ \ | |__ | |__ |9 |-> 3|
|
5
|
-
|____/[] \ ___ /[] |____/ /__ / \ __\ |_____| |_____| \___6__/
|
5
|
+
|____/[] \ ___ /[] |____/ /__ / \ __\ |_____| |_____| \___6__/
|
6
6
|
|
7
7
|
Movement has long been used to measure time. For example, the ball clock is a simple device which keeps track of the passing minutes by moving ball-bearings. Each minute, a rotating arm removes a ball bearing from the queue at the bottom, raises it to the top of the clock and deposits it on a track leading to indicators displaying minutes, five-minutes and hours. These indicators display the time between 1:00 and 12:59, but without 'a.m.' or 'p.m.' indicators. Thus 2 balls in the minute indicator, 6 balls in the five-minute indicator and 5 balls in the hour indicator displays the time 5:32.
|
8
8
|
|
@@ -11,7 +11,7 @@ Movement has long been used to measure time. For example, the ball clock is a si
|
|
11
11
|
| \_/ | / \ / __| / \ \\ || \\//
|
12
12
|
| | / _ \ | |__ | [ ] | \\ //\\
|
13
13
|
|_/\_/\_| /_/ \_\ \____| \___/ ||_\\ // \\
|
14
|
-
|
14
|
+
|
15
15
|
* Ruby -v 2.2.0+ # Use Rvm where possible `rvm install version_number`
|
16
16
|
* Install the clock `gem install danno_ball_clock` or clone it from this repo.
|
17
17
|
|
@@ -34,6 +34,9 @@ The Clock takes two parameters, the number of balls and the number of minutes to
|
|
34
34
|
# Using the Gem!
|
35
35
|
|
36
36
|
* `ruby -Ilib ./bin/clock {27,0}` or `ruby -Ilib ./bin/clock {30,325}` # if cloned
|
37
|
-
* `ruby -Ilib ~/.rvm/gems/ruby-2.2.3/gems/danno_ball_clock-0.0.
|
37
|
+
* `ruby -Ilib ~/.rvm/gems/ruby-2.2.3/gems/danno_ball_clock-0.0.3/bin/clock {33,90}` # if installed via `gem install`
|
38
38
|
|
39
|
+
# Testing the Gem!
|
39
40
|
|
41
|
+
* `rake` # if cloned
|
42
|
+
* `cd ~/.rvm/gems/ruby-2.2.3/gems/danno_ball_clock_0.0.3` then `rake` # if installed via `gem install`
|
data/lib/clock.rb
CHANGED
@@ -8,7 +8,8 @@ require 'json'
|
|
8
8
|
###
|
9
9
|
class Clock
|
10
10
|
###
|
11
|
-
# @method add_minute
|
11
|
+
# @method add_minute
|
12
|
+
# adds a ball from the begining of the main
|
12
13
|
# queue to the minute track. Once the minute track is full
|
13
14
|
# the ball will drop to the five minute track triggering in
|
14
15
|
# reverse order the minute track to deposit to the main queue.
|
@@ -50,7 +51,7 @@ class Clock
|
|
50
51
|
###
|
51
52
|
# @param [Fixnum, Fixnum] runs clock with number of balls to start with and optionally a runtime.
|
52
53
|
# @return [Json] json hash for min, five_min, hour and main queues. If no runtime
|
53
|
-
#
|
54
|
+
# is provided it will calculate the days tell the que repeats.
|
54
55
|
###
|
55
56
|
def self.run_ball_clock(balls, run_time)
|
56
57
|
@current_que = []
|
@@ -70,14 +71,13 @@ class Clock
|
|
70
71
|
until @repeat == true
|
71
72
|
add_minute
|
72
73
|
end
|
73
|
-
|
74
|
+
"Clock cycles in: #{@cycle_days} day\(s\)\."
|
74
75
|
else
|
75
76
|
until min_left == 0
|
76
77
|
add_minute
|
77
78
|
min_left -= 1
|
78
79
|
end
|
79
|
-
|
80
|
+
JSON.generate(min: @min_track, fiveMin: @five_min_track, hour: @hour_track, main: @current_que)
|
80
81
|
end
|
81
|
-
JSON.generate(json_clock)
|
82
82
|
end
|
83
83
|
end
|
data/test/test_clock.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'clock'
|
3
|
+
|
4
|
+
class ClockTest < Minitest::Test
|
5
|
+
def test_run_time
|
6
|
+
assert_equal "{\"min\":[],\"fiveMin\":[22,13,25,3,7],\"hour\":[6,12,17,4,15],\"main\":[11,5,26,18,2,30,19,8,24,10,29,20,16,21,28,1,23,14,27,9]}",
|
7
|
+
Clock.run_ball_clock(30,325)
|
8
|
+
end
|
9
|
+
def test_cycle_days
|
10
|
+
assert_equal "Clock cycles in: 2415 day(s).",
|
11
|
+
Clock.run_ball_clock(127,0)
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danno_ball_clock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danial Oberg
|
@@ -18,9 +18,13 @@ executables:
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- ".travis.yml"
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
21
24
|
- README.md
|
22
25
|
- bin/clock
|
23
26
|
- lib/clock.rb
|
27
|
+
- test/test_clock.rb
|
24
28
|
homepage: http://rubygems.org/gems/danno_ball_clock
|
25
29
|
licenses:
|
26
30
|
- MIT
|