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

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.



128
129
130
131
132
133
134
# File 'lib/presently/slide.rb', line 128

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.



143
144
145
# File 'lib/presently/slide.rb', line 143

def content
  @content
end

#front_matterObject (readonly)

Returns the value of attribute front_matter.



140
141
142
# File 'lib/presently/slide.rb', line 140

def front_matter
  @front_matter
end

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



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

attr :script

#notesObject (readonly)

Returns the value of attribute notes.



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

def notes
  @notes
end

#pathObject (readonly)

Returns the value of attribute path.



137
138
139
# File 'lib/presently/slide.rb', line 137

def path
  @path
end

#scriptObject (readonly)

Returns the value of attribute script.



149
150
151
# File 'lib/presently/slide.rb', line 149

def script
  @script
end

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



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

attr :content

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



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

attr :path

#The rendered HTML presenter notes.(renderedHTMLpresenternotes.) ⇒ Object (readonly)



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

attr :notes

Class Method Details

.load(path) ⇒ Object

Load and parse a slide from a Markdown file.



118
119
120
# File 'lib/presently/slide.rb', line 118

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

Instance Method Details

#durationObject

The expected duration of this slide in seconds.



159
160
161
# File 'lib/presently/slide.rb', line 159

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

#focusObject

The line range to focus on for code slides.



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

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.



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

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

#skip?Boolean

Whether this slide should be skipped in the presentation.

Returns:

  • (Boolean)


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

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

#templateObject

The template to use for rendering this slide.



153
154
155
# File 'lib/presently/slide.rb', line 153

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

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



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

attr :front_matter

#titleObject

The title of this slide.



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

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

#transitionObject

The transition type for animating into this slide.



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

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