console_splash 1.0.0 → 1.1.0
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/lib/console_splash.rb +11 -11
- metadata +1 -1
data/lib/console_splash.rb
CHANGED
|
@@ -8,7 +8,7 @@ class Console_Splash
|
|
|
8
8
|
# Create a new screen Array with a given console size
|
|
9
9
|
# (will be auto-generated otherwise using `stty size`)
|
|
10
10
|
def initialize(lines=nil, columns=nil)
|
|
11
|
-
@lines = lines ? lines :
|
|
11
|
+
@lines = lines ? lines : `stty size`.chomp.split()[0].to_i
|
|
12
12
|
@columns = columns ? columns : `stty size`.chomp.split()[1].to_i
|
|
13
13
|
@screen = Array.new(@lines, "#{' '*(@columns)}\n")
|
|
14
14
|
@screen[-1] = "#{' '*(@columns)}"
|
|
@@ -29,20 +29,20 @@ class Console_Splash
|
|
|
29
29
|
# Draw a continuous pattern on the top of the screen
|
|
30
30
|
def write_top_pattern(pattern="=")
|
|
31
31
|
strSize = pattern.size
|
|
32
|
-
|
|
32
|
+
write_line(0, "#{pattern*((@columns-1)/strSize)}")
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Draw a continuous pattern on the bottom of the screen
|
|
36
36
|
def write_bottom_pattern(pattern="=")
|
|
37
37
|
strSize = pattern.size
|
|
38
|
-
|
|
38
|
+
write_line(-1, "#{pattern*((@columns-1)/strSize)}")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# Draw a continuous pattern on the right side of the screen
|
|
42
42
|
def write_right_pattern(pattern="=")
|
|
43
43
|
count = 1
|
|
44
44
|
@screen[(1..-2)].each do |line|
|
|
45
|
-
|
|
45
|
+
write_line(count, pattern, (@columns-(pattern.size+1)))
|
|
46
46
|
count += 1
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -51,7 +51,7 @@ class Console_Splash
|
|
|
51
51
|
def write_left_pattern(pattern="=")
|
|
52
52
|
count = 1
|
|
53
53
|
@screen[(1..-2)].each do |line|
|
|
54
|
-
|
|
54
|
+
write_line(count, pattern)
|
|
55
55
|
count += 1
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -60,20 +60,20 @@ class Console_Splash
|
|
|
60
60
|
# and the version in a vim-esq manner
|
|
61
61
|
def write_header(name, author, version)
|
|
62
62
|
header = (@screen.size*(1.0/3.0)).to_i
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
write_center(header, name)
|
|
64
|
+
write_center(header+2, "version #{version}")
|
|
65
|
+
write_center(header+3, "by #{author}")
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Write to the center of the line
|
|
69
|
-
def
|
|
69
|
+
def write_center(line, text)
|
|
70
70
|
strSize = text.size
|
|
71
71
|
buffer = (@columns - strSize)/2.0
|
|
72
|
-
|
|
72
|
+
write_line(line, text, buffer)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# Writes on the lines of the screen
|
|
76
|
-
def
|
|
76
|
+
def write_line(line, text, start=0)
|
|
77
77
|
buffer = @screen[line].split('')
|
|
78
78
|
buffer[start..(start+text.size()-1)] = text.split('')
|
|
79
79
|
@screen[line] = buffer.join('')
|