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 front_matter for metadata (template, duration, focus), content sections split by Markdown headings, and optional presenter notes separated by ‘—`.
Defined Under Namespace
Modules: Parser
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#front_matter ⇒ Object
readonly
Returns the value of attribute front_matter.
-
#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
Class Method Summary collapse
-
.load(path) ⇒ Object
Load and parse a slide from a Markdown file.
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, front_matter: nil, content: {}, notes: nil) ⇒ Slide
constructor
Initialize a slide with pre-parsed data.
-
#marker ⇒ Object
The navigation marker for this slide, used in the presenter’s jump-to dropdown.
-
#skip? ⇒ Boolean
Whether this slide should be skipped in the presentation.
-
#template ⇒ Object
The template to use for rendering this slide.
- #The parsed YAML front_matter.=(parsedYAMLfront_matter. = (value)) ⇒ Object
-
#title ⇒ Object
The title of this slide.
-
#transition ⇒ Object
The transition type for animating into this slide.
Constructor Details
#initialize(path, front_matter: nil, content: {}, notes: nil) ⇒ Slide
Initialize a slide with pre-parsed data.
112 113 114 115 116 117 |
# File 'lib/presently/slide.rb', line 112 def initialize(path, front_matter: nil, content: {}, notes: nil) @path = path @front_matter = front_matter @content = content @notes = notes end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
126 127 128 |
# File 'lib/presently/slide.rb', line 126 def content @content end |
#front_matter ⇒ Object (readonly)
Returns the value of attribute front_matter.
123 124 125 |
# File 'lib/presently/slide.rb', line 123 def front_matter @front_matter end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
129 130 131 |
# File 'lib/presently/slide.rb', line 129 def notes @notes end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
120 121 122 |
# File 'lib/presently/slide.rb', line 120 def path @path end |
#The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object (readonly)
126 |
# File 'lib/presently/slide.rb', line 126 attr :content |
#The file path of the slide.(filepathoftheslide.) ⇒ Object (readonly)
120 |
# File 'lib/presently/slide.rb', line 120 attr :path |
#The rendered HTML presenter notes.(renderedHTMLpresenternotes.) ⇒ Object (readonly)
129 |
# File 'lib/presently/slide.rb', line 129 attr :notes |
Class Method Details
Instance Method Details
#duration ⇒ Object
The expected duration of this slide in seconds.
139 140 141 |
# File 'lib/presently/slide.rb', line 139 def duration @front_matter&.fetch("duration", 60) || 60 end |
#focus ⇒ Object
The line range to focus on for code slides.
169 170 171 172 173 174 |
# File 'lib/presently/slide.rb', line 169 def focus if range = @front_matter&.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.
157 158 159 |
# File 'lib/presently/slide.rb', line 157 def marker @front_matter&.fetch("marker", nil) end |
#skip? ⇒ Boolean
Whether this slide should be skipped in the presentation.
151 152 153 |
# File 'lib/presently/slide.rb', line 151 def skip? @front_matter&.fetch("skip", false) || false end |
#template ⇒ Object
The template to use for rendering this slide.
133 134 135 |
# File 'lib/presently/slide.rb', line 133 def template @front_matter&.fetch("template", "default") || "default" end |
#The parsed YAML front_matter.=(parsedYAMLfront_matter. = (value)) ⇒ Object
123 |
# File 'lib/presently/slide.rb', line 123 attr :front_matter |
#title ⇒ Object
The title of this slide.
145 146 147 |
# File 'lib/presently/slide.rb', line 145 def title @front_matter&.fetch("title", File.basename(@path, ".md")) || File.basename(@path, ".md") end |
#transition ⇒ Object
The transition type for animating into this slide.
163 164 165 |
# File 'lib/presently/slide.rb', line 163 def transition @front_matter&.fetch("transition", nil) end |