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 Classes: Fragment
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#front_matter ⇒ Object
readonly
Returns the value of attribute front_matter.
- #JavaScript to execute after the slide renders on the display.(toexecuteafterthesliderendersonthedisplay.) ⇒ Object readonly
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
- #The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object readonly
- #The file path of the slide.(filepathoftheslide.) ⇒ Object readonly
- #The presenter notes as a Markly AST fragment.(presenternotesasaMarklyASTfragment.) ⇒ 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, script: 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.
-
#speaker ⇒ Object
The name of the speaker presenting this slide.
-
#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, script: nil) ⇒ Slide
Initialize a slide with pre-parsed data.
198 199 200 201 202 203 204 |
# File 'lib/presently/slide.rb', line 198 def initialize(path, front_matter: nil, content: {}, notes: nil, script: nil) @path = path @front_matter = front_matter @content = content @notes = notes @script = script end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
213 214 215 |
# File 'lib/presently/slide.rb', line 213 def content @content end |
#front_matter ⇒ Object (readonly)
Returns the value of attribute front_matter.
210 211 212 |
# File 'lib/presently/slide.rb', line 210 def front_matter @front_matter end |
#JavaScript to execute after the slide renders on the display.(toexecuteafterthesliderendersonthedisplay.) ⇒ Object (readonly)
219 |
# File 'lib/presently/slide.rb', line 219 attr :script |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
216 217 218 |
# File 'lib/presently/slide.rb', line 216 def notes @notes end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
207 208 209 |
# File 'lib/presently/slide.rb', line 207 def path @path end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
219 220 221 |
# File 'lib/presently/slide.rb', line 219 def script @script end |
#The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object (readonly)
213 |
# File 'lib/presently/slide.rb', line 213 attr :content |
#The file path of the slide.(filepathoftheslide.) ⇒ Object (readonly)
207 |
# File 'lib/presently/slide.rb', line 207 attr :path |
#The presenter notes as a Markly AST fragment.(presenternotesasaMarklyASTfragment.) ⇒ Object (readonly)
216 |
# File 'lib/presently/slide.rb', line 216 attr :notes |
Class Method Details
Instance Method Details
#duration ⇒ Object
The expected duration of this slide in seconds.
229 230 231 |
# File 'lib/presently/slide.rb', line 229 def duration @front_matter&.fetch("duration", 60) || 60 end |
#focus ⇒ Object
The line range to focus on for code slides.
265 266 267 268 269 270 |
# File 'lib/presently/slide.rb', line 265 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.
247 248 249 |
# File 'lib/presently/slide.rb', line 247 def marker @front_matter&.fetch("marker", nil) end |
#skip? ⇒ Boolean
Whether this slide should be skipped in the presentation.
241 242 243 |
# File 'lib/presently/slide.rb', line 241 def skip? @front_matter&.fetch("skip", false) || false end |
#speaker ⇒ Object
The name of the speaker presenting this slide.
259 260 261 |
# File 'lib/presently/slide.rb', line 259 def speaker @front_matter&.fetch("speaker", nil) end |
#template ⇒ Object
The template to use for rendering this slide.
223 224 225 |
# File 'lib/presently/slide.rb', line 223 def template @front_matter&.fetch("template", "default") || "default" end |
#The parsed YAML front_matter.=(parsedYAMLfront_matter. = (value)) ⇒ Object
210 |
# File 'lib/presently/slide.rb', line 210 attr :front_matter |
#title ⇒ Object
The title of this slide.
235 236 237 |
# File 'lib/presently/slide.rb', line 235 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.
253 254 255 |
# File 'lib/presently/slide.rb', line 253 def transition @front_matter&.fetch("transition", nil) end |