Class: Presently::Slide
- Inherits:
-
Object
- Object
- Presently::Slide
- 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
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#frontmatter ⇒ Object
readonly
Returns the value of attribute frontmatter.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
- #The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object readonly
- #The file path of the slide.(filepathoftheslide.) ⇒ Object readonly
- #The rendered HTML presenter notes.(renderedHTMLpresenternotes.) ⇒ Object readonly
Instance Method Summary collapse
-
#duration ⇒ Object
The expected duration of this slide in seconds.
-
#focus ⇒ Object
The line range to focus on for code slides.
-
#initialize(path) ⇒ Slide
constructor
Initialize a new slide by parsing the given Markdown file.
-
#marker ⇒ Object
The navigation marker for this slide, used in the presenter’s jump-to dropdown.
-
#template ⇒ Object
The template to use for rendering this slide.
- #The parsed YAML frontmatter.=(parsedYAMLfrontmatter. = (value)) ⇒ Object
-
#title ⇒ Object
The title of this slide.
-
#transition ⇒ Object
The transition type for animating into this slide.
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
#content ⇒ Object (readonly)
Returns the value of attribute content.
33 34 35 |
# File 'lib/presently/slide.rb', line 33 def content @content end |
#frontmatter ⇒ Object (readonly)
Returns the value of attribute frontmatter.
30 31 32 |
# File 'lib/presently/slide.rb', line 30 def frontmatter @frontmatter end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
36 37 38 |
# File 'lib/presently/slide.rb', line 36 def notes @notes end |
#path ⇒ Object (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
#duration ⇒ Object
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 |
#focus ⇒ Object
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 |
#marker ⇒ Object
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 |
#template ⇒ Object
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 |
#title ⇒ Object
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 |
#transition ⇒ Object
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 |