ruby_figlet 0.2.1 → 0.2.2
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/README.md +4 -3
- data/bin/ruby-figlet +2 -1
- data/lib/figlet_interpreter.rb +13 -15
- data/lib/ruby_figlet.rb +23 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 581f31f99acc9ef55d8eea09a074b8254a578449
|
4
|
+
data.tar.gz: 6a9c6cd4545a14bd92c21ae571d436ff4b1b8394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6905fef1aa55856518d5b12a91c36549d06b951b3b6a0e5c7bb5fb38a91c2aabbfc15dc1d683060dd06213ffaa4c00b646f7f04ccb238b2569ae59adfe837e5f
|
7
|
+
data.tar.gz: 18f9498fd39aa41140d7e253e0a2d19ec389073fb0a1d195ce7e2b0f32f18571b0fd115a2ef846db252389bb28c75869f4f405a9c7c1528939e2248f6c0812b7
|
data/README.md
CHANGED
@@ -27,8 +27,9 @@ puts moo # Default font is 'standard' when no arguments given
|
|
27
27
|
|
28
28
|
# or just
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
print "meow...".art
|
31
|
+
print RubyFiglet::Figlet.new("meow...").stringify
|
32
|
+
RubyFiglet::Figlet.new("meow...").show # all work the same
|
32
33
|
|
33
34
|
# str.art(font)/str.art!(font) and RubyFiglet::Figlet.new(str, font) have a font parameter!
|
34
35
|
|
@@ -44,7 +45,7 @@ puts "Heizölrückstoßabdämpfung".art # =>
|
|
44
45
|
# |_| |_| \___||_|/___| \___/ |_||_| \__,_| \___||_|\_\|___/ \__| \___/ | ||_/ \__,_||_.__/ \__,_| \__,_||_| |_| |_|| .__/ |_| \__,_||_| |_| \__, |
|
45
46
|
# |_| |_| |___/
|
46
47
|
|
47
|
-
puts RubyFiglet::Figlet.new("It's an abstract sort of font", 'weird')
|
48
|
+
puts RubyFiglet::Figlet.new("It's an abstract sort of font", 'weird').stringify
|
48
49
|
|
49
50
|
bowl = "Soup?"
|
50
51
|
bowl.art! 'alphabet'
|
data/bin/ruby-figlet
CHANGED
data/lib/figlet_interpreter.rb
CHANGED
@@ -51,14 +51,10 @@ module FigFont
|
|
51
51
|
@tag_count = meta[8].to_i
|
52
52
|
end
|
53
53
|
# we've got the information, now delete it form the `lines`
|
54
|
-
(0..@commented).each { lines.delete_at 0 } #
|
55
|
-
|
56
|
-
# the next line has now become
|
57
|
-
# the first line, embarrassing how long that took.
|
54
|
+
(0..@commented).each { lines.delete_at 0 } # since I delete the first line, the next line has now become the first line,
|
55
|
+
|
58
56
|
endmark = lines[0][lines[0].length - 1]
|
59
|
-
(0..lines.size - 1).each
|
60
|
-
lines[i].gsub!(endmark, "")
|
61
|
-
end
|
57
|
+
(0..lines.size - 1).each { |i| lines[i].gsub!(endmark, "") } #remove endmarks
|
62
58
|
|
63
59
|
char_hash = Hash.new
|
64
60
|
(32..126).each do |code|
|
@@ -73,19 +69,23 @@ module FigFont
|
|
73
69
|
'ö' => Array.new(@height, String.new),
|
74
70
|
'ü' => Array.new(@height, String.new),
|
75
71
|
'ß' => Array.new(@height, String.new)
|
76
|
-
}) if lines.length > 95 * @height
|
72
|
+
}) if lines.length > 95 * @height # 95 is the range of the num. of the default chars
|
77
73
|
|
78
74
|
char_hash.each do |key, value|
|
79
|
-
|
80
|
-
char_hash[key][line] = lines[line]
|
81
|
-
end
|
75
|
+
@height.times { |line| char_hash[key][line] = lines[line] }
|
82
76
|
lines.slice! 0..@height - 1
|
83
77
|
end
|
84
78
|
|
85
79
|
smush! char_hash unless @old_lay == -1
|
86
80
|
char_hash.each do |key, arr|
|
87
|
-
|
81
|
+
@height.times { |i| char_hash[key][i] = arr[i].gsub(@hardblank, " ") }
|
88
82
|
end
|
83
|
+
|
84
|
+
# Add fake newline character
|
85
|
+
newline = Array.new(@height, String.new)
|
86
|
+
newline[-1] = 10.chr
|
87
|
+
char_hash[10.chr] = newline
|
88
|
+
|
89
89
|
return char_hash
|
90
90
|
end
|
91
91
|
|
@@ -97,9 +97,7 @@ module FigFont
|
|
97
97
|
same_at_index[down] = true if (letter_arr[down][over] == letter_arr[down + 1][over]) && (letter_arr[down][over] == ' ' && letter_arr[down + 1][over] == ' ')
|
98
98
|
end
|
99
99
|
if same_at_index.all?
|
100
|
-
|
101
|
-
hash[letter][down].delete_at! over
|
102
|
-
end
|
100
|
+
@height.times { |down| hash[letter][down].delete_at! over }
|
103
101
|
end
|
104
102
|
end # Pre-word smushing for each letter, when there is a consective vertical line of spaces, then smush them away
|
105
103
|
end
|
data/lib/ruby_figlet.rb
CHANGED
@@ -29,23 +29,33 @@ module RubyFiglet
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def stringify
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
breaks = @string.split "\n"
|
33
|
+
breaks.each_with_index do |break_line, i|
|
34
|
+
string = String.new
|
35
|
+
@height.times do |row|
|
36
|
+
break_line.each { |char| string << @lookup[char][row] }
|
37
|
+
string << "\n"
|
36
38
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
(0..(%x[tput cols].to_i - 1) - lines[0].length).each do # Holy Moly, from 0 to (terminal width minus 1) minus length of the ascii art word.
|
42
|
-
lines.each_with_index do |line, i|
|
43
|
-
lines[i].insert 0, " "
|
39
|
+
if @direction == 1
|
40
|
+
lines = string.split "\n"
|
41
|
+
(0..(%x[tput cols].to_i - 1) - lines[0].length).each do # Holy Moly, from 0 to (terminal width minus 1) minus length of the ascii art word.
|
42
|
+
lines.each_with_index { |line, j| lines[j].insert 0, " " }
|
44
43
|
end
|
44
|
+
string = lines.join "\n"
|
45
|
+
end
|
46
|
+
breaks[i] = string
|
47
|
+
end
|
48
|
+
string = breaks.join ""
|
49
|
+
|
50
|
+
lines = string.split "\n"
|
51
|
+
offset = 0
|
52
|
+
(lines.size).times do |j|
|
53
|
+
if lines[j - offset].strip.empty? # when a line is deleted, there must be an offset as the new array is now shorter (after a delete) so we must climb back up it, so that whe don't dlete wrong lines and try to access non-existent indices
|
54
|
+
lines.delete_at(j - offset) # Remove any empty lines
|
55
|
+
offset += 1
|
45
56
|
end
|
46
|
-
string = lines.join "\n"
|
47
57
|
end
|
48
|
-
return
|
58
|
+
return lines.join "\n"
|
49
59
|
end
|
50
60
|
|
51
61
|
def show
|