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) ⇒ Slide

Initialize a slide with pre-parsed data.



112
113
114
115
116
117
# File 'lib/presently/slide.rb', line 112

def initialize(path, front_matter: nil, content: {}, notes: nil)
	@path = path
	@front_matter = front_matter
	@content = content
	@notes = notes
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



126
127
128
# File 'lib/presently/slide.rb', line 126

def content
  @content
end

#front_matterObject (readonly)

Returns the value of attribute front_matter.



123
124
125
# File 'lib/presently/slide.rb', line 123

def front_matter
  @front_matter
end

#notesObject (readonly)

Returns the value of attribute notes.



129
130
131
# File 'lib/presently/slide.rb', line 129

def notes
  @notes
end

#pathObject (readonly)

Returns the value of attribute path.



120
121
122
# File 'lib/presently/slide.rb', line 120

def path
  @path
end

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



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

attr :content

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



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

attr :path

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



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

attr :notes

Class Method Details

.load(path) ⇒ Object

Load and parse a slide from a Markdown file.



103
104
105
# File 'lib/presently/slide.rb', line 103

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

Instance Method Details

#durationObject

The expected duration of this slide in seconds.



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

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

#focusObject

The line range to focus on for code slides.



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

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.



157
158
159
# File 'lib/presently/slide.rb', line 157

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

#skip?Boolean

Whether this slide should be skipped in the presentation.

Returns:

  • (Boolean)


151
152
153
# File 'lib/presently/slide.rb', line 151

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

#templateObject

The template to use for rendering this slide.



133
134
135
# File 'lib/presently/slide.rb', line 133

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

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



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

attr :front_matter

#titleObject

The title of this slide.



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

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

#transitionObject

The transition type for animating into this slide.



163
164
165
# File 'lib/presently/slide.rb', line 163

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