Class: Presently::Presentation

Inherits:
Object
  • Object
show all
Defined in:
lib/presently/presentation.rb

Overview

An immutable collection of slides with configuration.

Use Presentation.load to create a presentation from a directory of Markdown files. Each loaded Slide is attached to its presentation and identified by a path relative to the presentation root.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root = "slides", templates = Templates.for) ⇒ Presentation

Initialize a new presentation.



27
28
29
30
31
# File 'lib/presently/presentation.rb', line 27

def initialize(root = "slides", templates = Templates.for)
	@root = File.expand_path(root)
	@templates = templates
	@slides = load_slides
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



34
35
36
# File 'lib/presently/presentation.rb', line 34

def root
  @root
end

#slidesObject (readonly)

Returns the value of attribute slides.



37
38
39
# File 'lib/presently/presentation.rb', line 37

def slides
  @slides
end

#templatesObject (readonly)

Returns the value of attribute templates.



40
41
42
# File 'lib/presently/presentation.rb', line 40

def templates
  @templates
end

#The absolute root directory containing slide files.(absoluterootdirectorycontainingslidefiles.) ⇒ Object (readonly)



34
# File 'lib/presently/presentation.rb', line 34

attr :root

#The ordered list of slides.(orderedlistofslides.) ⇒ Object (readonly)



37
# File 'lib/presently/presentation.rb', line 37

attr :slides

Class Method Details

.load(root = "slides", templates = Templates.for) ⇒ Object

Load a presentation from a directory of Markdown slide files.



20
21
22
# File 'lib/presently/presentation.rb', line 20

def self.load(root = "slides", templates = Templates.for)
	new(root, templates)
end

Instance Method Details

#expected_time_at(index) ⇒ Object

Calculate the expected elapsed time for slides up to the given index.



57
58
59
# File 'lib/presently/presentation.rb', line 57

def expected_time_at(index)
	@slides[0...index].sum(&:duration)
end

#reloadObject

Return a new Presently::Presentation with freshly loaded slides and a cleared template cache.



63
64
65
# File 'lib/presently/presentation.rb', line 63

def reload
	self.class.new(@root, @templates.reload)
end

#slide_countObject

The number of slides in the presentation.



44
45
46
# File 'lib/presently/presentation.rb', line 44

def slide_count
	@slides.length
end

#The template resolver.=(templateresolver. = (value)) ⇒ Object



40
# File 'lib/presently/presentation.rb', line 40

attr :templates

#total_durationObject

The total expected duration of the presentation in seconds.



50
51
52
# File 'lib/presently/presentation.rb', line 50

def total_duration
	@slides.sum(&:duration)
end