Class: TP::Slide::Bulleted
Constant Summary
collapse
- BULLET =
"\u2022"
Instance Attribute Summary
Attributes inherited from TP::Slide
#markdown
Instance Method Summary
collapse
Methods inherited from TP::Slide
#centered_header, #content, #hard_width?, #header, #height, #initialize, #lines, #pdf_content_height, #pdf_content_top_left, #pdf_header_height
Constructor Details
This class inherits a constructor from TP::Slide
Instance Method Details
#bullet_length ⇒ Object
33
34
35
|
# File 'lib/tp/slide/bulleted.rb', line 33
def bullet_length
BULLET.length + 1
end
|
#bullets ⇒ Object
29
30
31
|
# File 'lib/tp/slide/bulleted.rb', line 29
def bullets
content.lines.to_a.map { |line| line.gsub(/^[\*|-]\s/, "").strip }
end
|
#frames ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/tp/slide/bulleted.rb', line 41
def frames
return @frames if @frames
buffer =
buffer << "\n\n"
@frames = [buffer.dup]
bullets.each do |line|
buffer << "#{BULLET} #{line}\n"
@frames << buffer.dup
end
@frames
end
|
#render_pdf(pdf) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/tp/slide/bulleted.rb', line 4
def render_pdf(pdf)
pdf.text_box ,
align: :center,
overflow: :shrink_to_fit,
single_line: true,
height: ,
size:
pdf.text_box rendered_bullets,
at: pdf_content_top_left(pdf),
height: pdf_content_height(pdf),
overflow: :shrink_to_fit,
valign: :center
end
|
#render_terminal ⇒ Object
19
20
21
|
# File 'lib/tp/slide/bulleted.rb', line 19
def render_terminal
frames.last
end
|
#rendered_bullets ⇒ Object
37
38
39
|
# File 'lib/tp/slide/bulleted.rb', line 37
def rendered_bullets
bullets.map { |text| "#{BULLET} #{text}" }.join("\n")
end
|
#width ⇒ Object
23
24
25
26
27
|
# File 'lib/tp/slide/bulleted.rb', line 23
def width
= .length
longest_bullet = bullets.collect(&:length).max + bullet_length
[, longest_bullet].max
end
|