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(path, front_matter: nil, content: {}, notes: nil, script: nil) ⇒ Slide

Initialize a slide with pre-parsed data.



157
158
159
160
161
162
163
# File 'lib/presently/slide.rb', line 157

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

#contentObject (readonly)

Returns the value of attribute content.



172
173
174
# File 'lib/presently/slide.rb', line 172

def content
  @content
end

#front_matterObject (readonly)

Returns the value of attribute front_matter.



169
170
171
# File 'lib/presently/slide.rb', line 169

def front_matter
  @front_matter
end

#JavaScript to execute after the slide renders on the display.(toexecuteafterthesliderendersonthedisplay.) ⇒ Object (readonly)



178
# File 'lib/presently/slide.rb', line 178

attr :script

#notesObject (readonly)

Returns the value of attribute notes.



175
176
177
# File 'lib/presently/slide.rb', line 175

def notes
  @notes
end

#pathObject (readonly)

Returns the value of attribute path.



166
167
168
# File 'lib/presently/slide.rb', line 166

def path
  @path
end

#scriptObject (readonly)

Returns the value of attribute script.



178
179
180
# File 'lib/presently/slide.rb', line 178

def script
  @script
end

#The content sections keyed by heading name.(contentsectionskeyedbyheadingname.) ⇒ Object (readonly)



172
# File 'lib/presently/slide.rb', line 172

attr :content

#The file path of the slide.(filepathoftheslide.) ⇒ Object (readonly)



166
# File 'lib/presently/slide.rb', line 166

attr :path

#The presenter notes as a Markly AST fragment.(presenternotesasaMarklyASTfragment.) ⇒ Object (readonly)



175
# File 'lib/presently/slide.rb', line 175

attr :notes

Class Method Details

.load(path) ⇒ Object

Load and parse a slide from a Markdown file.



147
148
149
# File 'lib/presently/slide.rb', line 147

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

Instance Method Details

#durationObject

The expected duration of this slide in seconds.



188
189
190
# File 'lib/presently/slide.rb', line 188

def duration
	@front_matter&.fetch("duration", 60) || 60
end

#focusObject

The line range to focus on for code slides.



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

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.



206
207
208
# File 'lib/presently/slide.rb', line 206

def marker
	@front_matter&.fetch("marker", nil)
end

#skip?Boolean

Whether this slide should be skipped in the presentation.

Returns:

  • (Boolean)


200
201
202
# File 'lib/presently/slide.rb', line 200

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

#speakerObject

The name of the speaker presenting this slide.



218
219
220
# File 'lib/presently/slide.rb', line 218

def speaker
	@front_matter&.fetch("speaker", nil)
end

#templateObject

The template to use for rendering this slide.



182
183
184
# File 'lib/presently/slide.rb', line 182

def template
	@front_matter&.fetch("template", "default") || "default"
end

#The parsed YAML front_matter.=(parsedYAMLfront_matter. = (value)) ⇒ Object



169
# File 'lib/presently/slide.rb', line 169

attr :front_matter

#titleObject

The title of this slide.



194
195
196
# File 'lib/presently/slide.rb', line 194

def title
	@front_matter&.fetch("title", File.basename(@path, ".md")) || File.basename(@path, ".md")
end

#transitionObject

The transition type for animating into this slide.



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

def transition
	@front_matter&.fetch("transition", nil)
end