seven_segment_display 0.0.3 → 0.0.4
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.
- data/History.txt +3 -3
- data/README.rdoc +14 -24
- data/lib/seven_segment_display.rb +18 -11
- data/test/test_seven_segment_display.rb +18 -0
- metadata +4 -4
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -4,11 +4,11 @@ http://github.com/davidcole/seven_segment_display
|
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
Converts numbers to seven segment display digits, as in a digital clock, by adding a monkeypatch Integer.
|
7
|
+
Converts numbers to seven segment display digits, as in a digital clock, by adding a monkeypatch to Integer.
|
8
8
|
|
9
9
|
== FEATURES/PROBLEMS:
|
10
10
|
|
11
|
-
|
11
|
+
Positive and negative integers.
|
12
12
|
|
13
13
|
== SYNOPSIS:
|
14
14
|
|
@@ -16,8 +16,8 @@ Stay tuned.
|
|
16
16
|
require 'seven_segment_display'
|
17
17
|
|
18
18
|
puts 0.seven_segment
|
19
|
-
puts 42.seven_segment
|
20
|
-
puts 1029384756.seven_segment
|
19
|
+
puts 42.seven_segment
|
20
|
+
puts 1029384756.seven_segment
|
21
21
|
|
22
22
|
Outputs:
|
23
23
|
|
@@ -26,26 +26,16 @@ Outputs:
|
|
26
26
|
|
27
27
|
| |
|
28
28
|
—
|
29
|
-
|
30
|
-
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
||
|
40
|
-
||
|
41
|
-
—————
|
42
|
-
—— —— —— —— —— —— —— ——
|
43
|
-
|| | || | || || | || |
|
44
|
-
|| | || | || || | || |
|
45
|
-
—— —— —— —— —— —— ——
|
46
|
-
|| || | || | | | || |
|
47
|
-
|| || | || | | | || |
|
48
|
-
—— —— —— —— —— —— ——
|
29
|
+
—
|
30
|
+
| | |
|
31
|
+
— —
|
32
|
+
||
|
33
|
+
—
|
34
|
+
— — — — — — — —
|
35
|
+
|| | || | || || | || |
|
36
|
+
— — — — — — —
|
37
|
+
|| || | || | | | || |
|
38
|
+
— — — — — — —
|
49
39
|
|
50
40
|
== REQUIREMENTS:
|
51
41
|
|
@@ -11,75 +11,82 @@ module SevenSegmentDisplay
|
|
11
11
|
BOTTOM = 4
|
12
12
|
|
13
13
|
number_layouts = {
|
14
|
-
0 => {
|
14
|
+
'0' => {
|
15
15
|
TOP => [ ' ', '—', ' ' ],
|
16
16
|
TOP_BODY => [ '|', ' ', '|' ],
|
17
17
|
MIDDLE => [ ' ', ' ', ' ' ],
|
18
18
|
BOTTOM_BODY => [ '|', ' ', '|' ],
|
19
19
|
BOTTOM => [ ' ', '—', ' ' ]
|
20
20
|
},
|
21
|
-
1 => {
|
21
|
+
'1' => {
|
22
22
|
TOP => [ ' ', ' ', ' ' ],
|
23
23
|
TOP_BODY => [ ' ', ' ', '|' ],
|
24
24
|
MIDDLE => [ ' ', ' ', ' ' ],
|
25
25
|
BOTTOM_BODY => [ ' ', ' ', '|' ],
|
26
26
|
BOTTOM => [ ' ', ' ', ' ' ]
|
27
27
|
},
|
28
|
-
2 => {
|
28
|
+
'2' => {
|
29
29
|
TOP => [ ' ', '—', ' ' ],
|
30
30
|
TOP_BODY => [ ' ', ' ', '|' ],
|
31
31
|
MIDDLE => [ ' ', '—', ' ' ],
|
32
32
|
BOTTOM_BODY => [ '|', ' ', ' ' ],
|
33
33
|
BOTTOM => [ ' ', '—', ' ' ]
|
34
34
|
},
|
35
|
-
3 => {
|
35
|
+
'3' => {
|
36
36
|
TOP => [ ' ', '—', ' ' ],
|
37
37
|
TOP_BODY => [ ' ', ' ', '|' ],
|
38
38
|
MIDDLE => [ ' ', '—', ' ' ],
|
39
39
|
BOTTOM_BODY => [ ' ', ' ', '|' ],
|
40
40
|
BOTTOM => [ ' ', '—', ' ' ]
|
41
41
|
},
|
42
|
-
4 => {
|
42
|
+
'4' => {
|
43
43
|
TOP => [ ' ', ' ', ' ' ],
|
44
44
|
TOP_BODY => [ '|', ' ', '|' ],
|
45
45
|
MIDDLE => [ ' ', '—', ' ' ],
|
46
46
|
BOTTOM_BODY => [ ' ', ' ', '|' ],
|
47
47
|
BOTTOM => [ ' ', ' ', ' ' ]
|
48
48
|
},
|
49
|
-
5 => {
|
49
|
+
'5' => {
|
50
50
|
TOP => [ ' ', '—', ' ' ],
|
51
51
|
TOP_BODY => [ '|', ' ', ' ' ],
|
52
52
|
MIDDLE => [ ' ', '—', ' ' ],
|
53
53
|
BOTTOM_BODY => [ ' ', ' ', '|' ],
|
54
54
|
BOTTOM => [ ' ', '—', ' ' ]
|
55
55
|
},
|
56
|
-
6 => {
|
56
|
+
'6' => {
|
57
57
|
TOP => [ ' ', '—', ' ' ],
|
58
58
|
TOP_BODY => [ '|', ' ', ' ' ],
|
59
59
|
MIDDLE => [ ' ', '—', ' ' ],
|
60
60
|
BOTTOM_BODY => [ '|', ' ', '|' ],
|
61
61
|
BOTTOM => [ ' ', '—', ' ' ]
|
62
62
|
},
|
63
|
-
7 => {
|
63
|
+
'7' => {
|
64
64
|
TOP => [ ' ', '—', ' ' ],
|
65
65
|
TOP_BODY => [ ' ', ' ', '|' ],
|
66
66
|
MIDDLE => [ ' ', ' ', ' ' ],
|
67
67
|
BOTTOM_BODY => [ ' ', ' ', '|' ],
|
68
68
|
BOTTOM => [ ' ', ' ', ' ' ]
|
69
69
|
},
|
70
|
-
8 => {
|
70
|
+
'8' => {
|
71
71
|
TOP => [ ' ', '—', ' ' ],
|
72
72
|
TOP_BODY => [ '|', ' ', '|' ],
|
73
73
|
MIDDLE => [ ' ', '—', ' ' ],
|
74
74
|
BOTTOM_BODY => [ '|', ' ', '|' ],
|
75
75
|
BOTTOM => [ ' ', '—', ' ' ]
|
76
76
|
},
|
77
|
-
9 => {
|
77
|
+
'9' => {
|
78
78
|
TOP => [ ' ', '—', ' ' ],
|
79
79
|
TOP_BODY => [ '|', ' ', '|' ],
|
80
80
|
MIDDLE => [ ' ', '—', ' ' ],
|
81
81
|
BOTTOM_BODY => [ ' ', ' ', '|' ],
|
82
82
|
BOTTOM => [ ' ', '—', ' ' ]
|
83
|
+
},
|
84
|
+
'-' => {
|
85
|
+
TOP => [ ' ', ' ', ' ' ],
|
86
|
+
TOP_BODY => [ ' ', ' ', ' ' ],
|
87
|
+
MIDDLE => [ ' ', '—', ' ' ],
|
88
|
+
BOTTOM_BODY => [ ' ', ' ', ' ' ],
|
89
|
+
BOTTOM => [ ' ', ' ', ' ' ]
|
83
90
|
}
|
84
91
|
}
|
85
92
|
|
@@ -93,7 +100,7 @@ module SevenSegmentDisplay
|
|
93
100
|
make_line = lambda { | line_number |
|
94
101
|
line = ''
|
95
102
|
0.upto( number_count - 1 ) do | digit_index |
|
96
|
-
number_layout = number_layouts[ digits[ digit_index ]
|
103
|
+
number_layout = number_layouts[ digits[ digit_index ] ]
|
97
104
|
line << "#{ number_layout[ line_number ][ 0 ] }#{ number_layout[ line_number ][ 1 ] * size }#{ number_layout[ line_number ][ 2 ] }"
|
98
105
|
end
|
99
106
|
line + "\n"
|
@@ -42,6 +42,22 @@ class TestSevenSegmentDisplay < Test::Unit::TestCase
|
|
42
42
|
|| | | || | || | || |
|
43
43
|
|| | | || | || | || |
|
44
44
|
————— ————— ————— ————— ————— ————— —————
|
45
|
+
END
|
46
|
+
@all_digits_negative = <<-END
|
47
|
+
— —
|
48
|
+
| | |
|
49
|
+
— — —
|
50
|
+
|| |
|
51
|
+
— —
|
52
|
+
END
|
53
|
+
@all_digits_negative_2 = <<-END
|
54
|
+
—— ——
|
55
|
+
| | |
|
56
|
+
| | |
|
57
|
+
—— —— ——
|
58
|
+
|| |
|
59
|
+
|| |
|
60
|
+
—— ——
|
45
61
|
END
|
46
62
|
end
|
47
63
|
|
@@ -50,6 +66,8 @@ class TestSevenSegmentDisplay < Test::Unit::TestCase
|
|
50
66
|
assert_equal( @all_digits_backwards, 9876543210.seven_segment )
|
51
67
|
assert_equal( @all_digits_2, 1234567890.seven_segment( 2 ) )
|
52
68
|
assert_equal( @all_digits_5, 1234567890.seven_segment( 5 ) )
|
69
|
+
assert_equal( @all_digits_negative, -123.seven_segment )
|
70
|
+
assert_equal( @all_digits_negative_2, -123.seven_segment( 2 ) )
|
53
71
|
assert_raise( ArgumentError ) { 1234567890.seven_segment( 0 ) }
|
54
72
|
end
|
55
73
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Cole
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version: 2.6.0
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id002
|
48
|
-
description: Converts numbers to seven segment display digits, as in a digital clock, by adding a monkeypatch Integer.
|
48
|
+
description: Converts numbers to seven segment display digits, as in a digital clock, by adding a monkeypatch to Integer.
|
49
49
|
email:
|
50
50
|
- davidcole@davidcole.net
|
51
51
|
executables: []
|
@@ -96,7 +96,7 @@ rubyforge_project: seven-segment
|
|
96
96
|
rubygems_version: 1.3.6
|
97
97
|
signing_key:
|
98
98
|
specification_version: 3
|
99
|
-
summary: Converts numbers to seven segment display digits, as in a digital clock, by adding a monkeypatch Integer.
|
99
|
+
summary: Converts numbers to seven segment display digits, as in a digital clock, by adding a monkeypatch to Integer.
|
100
100
|
test_files:
|
101
101
|
- test/test_helper.rb
|
102
102
|
- test/test_seven_segment_display.rb
|