Class: Presently::Slide

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

Overview

A single slide parsed from a Markdown file.

Each slide has YAML frontmatter for metadata (template, duration, focus), content sections split by Markdown headings, and optional presenter notes separated by ‘—`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Slide

Initialize a new slide by parsing the given Markdown file.



17
18
19
20
21
22
23
24
# File 'lib/presently/slide.rb', line 17

def initialize(path)
	@path = path
	@frontmatter = nil
	@content = nil
	@notes = nil
	
	parse!
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



33
34
35
# File 'lib/presently/slide.rb', line 33

def content
  @content
end

#frontmatterObject (readonly)

Returns the value of attribute frontmatter.



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

def frontmatter
  @frontmatter
end

#notesObject (readonly)

Returns the value of attribute notes.



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

def notes
  @notes
end

#pathObject (readonly)

Returns the value of attribute path.



27
28
29
# File 'lib/presently/slide.rb', line 27

def path
  @path
end

#The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object (readonly)



33
# File 'lib/presently/slide.rb', line 33

attr :content

#The file path of the slide.(filepathoftheslide.) ⇒ Object (readonly)



27
# File 'lib/presently/slide.rb', line 27

attr :path

#The rendered HTML presenter notes.(renderedHTMLpresenternotes.) ⇒ Object (readonly)



36
# File 'lib/presently/slide.rb', line 36

attr :notes

Instance Method Details

#durationObject

The expected duration of this slide in seconds.



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

def duration
	@frontmatter&.fetch("duration", 60) || 60
end

#focusObject

The line range to focus on for code slides.



70
71
72
73
74
75
# File 'lib/presently/slide.rb', line 70

def focus
	if range = @frontmatter&.fetch("focus", nil)
		parts = range.to_s.split("-").map(&:to_i)
		parts.length == 2 ? parts : nil
	end
end

#markerObject

The navigation marker for this slide, used in the presenter’s jump-to dropdown.



58
59
60
# File 'lib/presently/slide.rb', line 58

def marker
	@frontmatter&.fetch("marker", nil)
end

#templateObject

The template to use for rendering this slide.



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

def template
	@frontmatter&.fetch("template", "default") || "default"
end

#The parsed YAML frontmatter.=(parsedYAMLfrontmatter. = (value)) ⇒ Object



30
# File 'lib/presently/slide.rb', line 30

attr :frontmatter

#titleObject

The title of this slide.



52
53
54
# File 'lib/presently/slide.rb', line 52

def title
	@frontmatter&.fetch("title", File.basename(@path, ".md")) || File.basename(@path, ".md")
end

#transitionObject

The transition type for animating into this slide.



64
65
66
# File 'lib/presently/slide.rb', line 64

def transition
	@frontmatter&.fetch("transition", nil)
end