dgoodlad-slider 0.1.0 → 0.1.1
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/README +21 -0
- data/doc/example.rb +5 -1
- data/lib/slider.rb +23 -7
- data/slider.gemspec +1 -1
- metadata +1 -1
data/README
CHANGED
@@ -2,4 +2,25 @@ Slider is a simple Ruby module to allow a presenter to create and view a
|
|
2
2
|
slideshow using only a terminal emulator. It requires the use of the console
|
3
3
|
application 'figlet' to draw the fancy headings.
|
4
4
|
|
5
|
+
Configuration:
|
6
|
+
|
7
|
+
- Set the # of columns in your terminal window (default is 80).
|
8
|
+
set_columns 105
|
9
|
+
|
10
|
+
- Set the # of rows in your terminal window (default is 24).
|
11
|
+
set_rows 30
|
12
|
+
|
13
|
+
- Set the FIGlet font of choice. See the FIGlet man page for more info.
|
14
|
+
set_figlet_font 'bubble'
|
15
|
+
|
16
|
+
Create slides:
|
17
|
+
- Set the header (first argument), and sub-points (subsequent arguments) each
|
18
|
+
separated by a comma.
|
19
|
+
|
20
|
+
slide "Slider", "It's cool!"
|
21
|
+
|
22
|
+
Run the show:
|
23
|
+
|
24
|
+
start_slideshow
|
25
|
+
|
5
26
|
This code is provided under the MIT license, included in the file MIT-LICENSE
|
data/doc/example.rb
CHANGED
data/lib/slider.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
module Slider
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
@@columns = 80
|
4
|
+
@@rows = 24
|
5
|
+
@@figlet_font = 'standard'
|
6
|
+
#COLUMNS = 105
|
7
|
+
#ROWS = 30
|
4
8
|
VERTICAL_PADDING = 10
|
5
|
-
FIGLET_FONT = 'standard'
|
9
|
+
#FIGLET_FONT = 'standard'
|
6
10
|
|
11
|
+
def set_columns(c)
|
12
|
+
@@columns = c
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_rows(r)
|
16
|
+
@@rows = r
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_figlet_font(f)
|
20
|
+
@@figlet_font = f
|
21
|
+
end
|
22
|
+
|
7
23
|
def slide(heading, *text)
|
8
24
|
@slides ||= []
|
9
25
|
@slides << [heading] + text
|
@@ -21,13 +37,13 @@ module Slider
|
|
21
37
|
|
22
38
|
private
|
23
39
|
def render_slide(heading, *text)
|
24
|
-
heading = `figlet -f #{
|
40
|
+
heading = `figlet -f #{@@figlet_font} #{heading}`
|
25
41
|
width = heading.map { |line| line.length }.max
|
26
|
-
padding = " " * ((
|
42
|
+
padding = " " * ((@@columns - width) / 2)
|
27
43
|
heading = heading.map { |line| "#{padding}#{line}" }
|
28
44
|
heading_height = heading.size
|
29
45
|
text = text.map { |line|
|
30
|
-
padding = " " * ((
|
46
|
+
padding = " " * ((@@columns - line.length) / 2)
|
31
47
|
"#{padding}#{line}\n"
|
32
48
|
}
|
33
49
|
|
@@ -35,7 +51,7 @@ module Slider
|
|
35
51
|
result << heading.join
|
36
52
|
result << "\n"
|
37
53
|
result << text.join
|
38
|
-
result << "\n" * (
|
54
|
+
result << "\n" * (@@rows - VERTICAL_PADDING - heading_height - text.size)
|
39
55
|
result
|
40
56
|
end
|
41
57
|
|
data/slider.gemspec
CHANGED