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
# File 'lib/tp/slide.rb', line 18

def content
  Array(lines[2, lines.count - 2]).join
end

#framesObject



22
23
24
# File 'lib/tp/slide.rb', line 22

def frames
  [render_terminal]
end

#hard_width?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/tp/slide.rb', line 46

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



42
43
44
# File 'lib/tp/slide.rb', line 42

def height
  lines.count
end

#linesObject



26
27
28
# File 'lib/tp/slide.rb', line 26

def lines
  markdown.lines.to_a
end

#pdf_content_height(pdf) ⇒ Object



30
31
32
# File 'lib/tp/slide.rb', line 30

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

#pdf_content_top_left(pdf) ⇒ Object



34
35
36
# File 'lib/tp/slide.rb', line 34

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

#pdf_header_heightObject



38
39
40
# File 'lib/tp/slide.rb', line 38

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