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 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

Class Method Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



227
228
229
# File 'lib/presently/slide.rb', line 227

def content
  @content
end

#front_matterObject (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

#notesObject (readonly)

Returns the value of attribute notes.



230
231
232
# File 'lib/presently/slide.rb', line 230

def notes
  @notes
end

#pathObject (readonly)

Returns the value of attribute path.



215
216
217
# File 'lib/presently/slide.rb', line 215

def path
  @path
end

#presentationObject (readonly)

Returns the value of attribute presentation.



212
213
214
# File 'lib/presently/slide.rb', line 212

def presentation
  @presentation
end

#scriptObject (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

.load(presentation, path) ⇒ Object

Load and parse a slide from a Markdown file.



191
192
193
# File 'lib/presently/slide.rb', line 191

def self.load(presentation, path)
	Parser.load(presentation, path)
end

Instance Method Details

#durationObject

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

#focusObject

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

#markerObject

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.

Returns:

  • (Boolean)


255
256
257
# File 'lib/presently/slide.rb', line 255

def skip?
	@front_matter&.fetch("skip", false) || false
end

#source_pathObject

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

#speakerObject

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

#templateObject

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

#titleObject

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

#transitionObject

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