2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/obs_deck/modules/my_methods.rb', line 2
def self.create_card(card_sample, max_width = 60)
if card_sample == "Pae White's non-blank graphic metacard"
card =
<<~HEREDOC
–––––––––––––––––––––––––––––––––––––––––––––––––––
| |
| |
| |
| |
| |
| |
–––––––––––––––––––––––––––––––––––––––––––––––––––
Pae White's non-blank graphic metacard
HEREDOC
else
words = card_sample.split(' ')
lines = []
current_line = ""
words.each do |word|
if (current_line + word).length <= max_width
current_line += "#{word} "
else
lines << current_line.strip
current_line = "#{word} "
end
end
lines << current_line.strip unless current_line.empty?
card_width = max_width
border = "–" * (card_width + 4)
card = "#{border}\n"
card += "| #{' ' * card_width} |\n"
lines.each do |line|
padding = (card_width - line.length) / 2
centered_line = ' ' * padding + line
card += "| #{centered_line.ljust(card_width)} |\n"
card += "| #{' ' * card_width} |\n"
end
card += border
card
end
end
|