Class: TP::Slide

Inherits:
Object
  • Object
show all
Defined in:
lib/tp/slide.rb

Direct Known Subclasses

Bulleted, Code, HeaderOnly, Paragraph

Defined Under Namespace

Classes: Bulleted, Code, HeaderOnly, Paragraph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(markdown) ⇒ Slide

Returns a new instance of Slide.



5
6
7
# File 'lib/tp/slide.rb', line 5

def initialize(markdown)
  @markdown = markdown.strip
end

Instance Attribute Details

#markdownObject (readonly)

Returns the value of attribute markdown.



3
4
5
# File 'lib/tp/slide.rb', line 3

def markdown
  @markdown
end

Instance Method Details

#centered_headerObject



14
15
16
# File 'lib/tp/slide.rb', line 14

def centered_header
  header.center Screen.width
end

#contentObject



18
19
20
21
22
# File 'lib/tp/slide.rb', line 18

def content
  Array(lines[2, lines.count - 2]).reject { |line|
    line.start_with?("> ")
  }.join
end

#framesObject



24
25
26
# File 'lib/tp/slide.rb', line 24

def frames
  [render_terminal]
end

#hard_width?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/tp/slide.rb', line 48

def hard_width?
  true
end

#headerObject



9
10
11
12
# File 'lib/tp/slide.rb', line 9

def header
  line = lines.first
  line[1, line.length - 1].to_s.strip
end

#heightObject



44
45
46
# File 'lib/tp/slide.rb', line 44

def height
  lines.count
end

#linesObject



28
29
30
# File 'lib/tp/slide.rb', line 28

def lines
  markdown.lines.to_a
end

#pdf_content_height(pdf) ⇒ Object



32
33
34
# File 'lib/tp/slide.rb', line 32

def pdf_content_height(pdf)
  pdf.bounds.height - pdf_header_height
end

#pdf_content_top_left(pdf) ⇒ Object



36
37
38
# File 'lib/tp/slide.rb', line 36

def pdf_content_top_left(pdf)
  [pdf.bounds.left, pdf.bounds.top - pdf_header_height]
end

#pdf_header_heightObject



40
41
42
# File 'lib/tp/slide.rb', line 40

def pdf_header_height
  header != "" ? 1.in : 0
end