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.
-
#presentation ⇒ Object
readonly
Returns the value of attribute presentation.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
- #The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object readonly
- #The presentation which owns the slide.(presentationwhichownstheslide.) ⇒ Object readonly
- #The presenter notes as a Markly AST fragment.(presenternotesasaMarklyASTfragment.) ⇒ Object readonly
- #The slide path relative to the presentation root.(slidepathrelativetothepresentationroot.) ⇒ Object readonly
Class Method Summary collapse
-
.load(presentation, 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(presentation, 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.
-
#source_path ⇒ Object
The absolute path of the slide source file.
-
#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(presentation, path, front_matter: nil, content: {}, notes: nil, script: nil) ⇒ Slide
Initialize a slide with pre-parsed data.
202 203 204 205 206 207 208 209 |
# File 'lib/presently/slide.rb', line 202 def initialize(presentation, path, front_matter: nil, content: {}, notes: nil, script: nil) @presentation = presentation @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.
227 228 229 |
# File 'lib/presently/slide.rb', line 227 def content @content end |
#front_matter ⇒ Object (readonly)
Returns the value of attribute front_matter.
224 225 226 |
# File 'lib/presently/slide.rb', line 224 def front_matter @front_matter end |
#JavaScript to execute after the slide renders on the display.(toexecuteafterthesliderendersonthedisplay.) ⇒ Object (readonly)
233 |
# File 'lib/presently/slide.rb', line 233 attr :script |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
230 231 232 |
# File 'lib/presently/slide.rb', line 230 def notes @notes end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
215 216 217 |
# File 'lib/presently/slide.rb', line 215 def path @path end |
#presentation ⇒ Object (readonly)
Returns the value of attribute presentation.
212 213 214 |
# File 'lib/presently/slide.rb', line 212 def presentation @presentation end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
233 234 235 |
# File 'lib/presently/slide.rb', line 233 def script @script end |
#The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object (readonly)
227 |
# File 'lib/presently/slide.rb', line 227 attr :content |
#The presentation which owns the slide.(presentationwhichownstheslide.) ⇒ Object (readonly)
212 |
# File 'lib/presently/slide.rb', line 212 attr :presentation |
#The presenter notes as a Markly AST fragment.(presenternotesasaMarklyASTfragment.) ⇒ Object (readonly)
230 |
# File 'lib/presently/slide.rb', line 230 attr :notes |
#The slide path relative to the presentation root.(slidepathrelativetothepresentationroot.) ⇒ Object (readonly)
215 |
# File 'lib/presently/slide.rb', line 215 attr :path |
Class Method Details
Instance Method Details
#duration ⇒ Object
The expected duration of this slide in seconds.
243 244 245 |
# File 'lib/presently/slide.rb', line 243 def duration @front_matter&.fetch("duration", 60) || 60 end |
#focus ⇒ Object
The line range to focus on for code slides.
279 280 281 282 283 284 |
# File 'lib/presently/slide.rb', line 279 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.
261 262 263 |
# File 'lib/presently/slide.rb', line 261 def marker @front_matter&.fetch("marker", nil) end |
#skip? ⇒ Boolean
Whether this slide should be skipped in the presentation.
255 256 257 |
# File 'lib/presently/slide.rb', line 255 def skip? @front_matter&.fetch("skip", false) || false end |
#source_path ⇒ Object
The absolute path of the slide source file.
219 220 221 |
# File 'lib/presently/slide.rb', line 219 def source_path File.join(@presentation.root, @path) end |
#speaker ⇒ Object
The name of the speaker presenting this slide.
273 274 275 |
# File 'lib/presently/slide.rb', line 273 def speaker @front_matter&.fetch("speaker", nil) end |
#template ⇒ Object
The template to use for rendering this slide.
237 238 239 |
# File 'lib/presently/slide.rb', line 237 def template @front_matter&.fetch("template", "default") || "default" end |
#The parsed YAML front_matter.=(parsedYAMLfront_matter. = (value)) ⇒ Object
224 |
# File 'lib/presently/slide.rb', line 224 attr :front_matter |
#title ⇒ Object
The title of this slide.
249 250 251 |
# File 'lib/presently/slide.rb', line 249 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.
267 268 269 |
# File 'lib/presently/slide.rb', line 267 def transition @front_matter&.fetch("transition", nil) end |