Class: Presently::Presentation
- Inherits:
-
Object
- Object
- Presently::Presentation
- 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
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#slides ⇒ Object
readonly
Returns the value of attribute slides.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
- #The absolute root directory containing slide files.(absoluterootdirectorycontainingslidefiles.) ⇒ Object readonly
- #The ordered list of slides.(orderedlistofslides.) ⇒ Object readonly
Class Method Summary collapse
-
.load(root = "slides", templates = Templates.for) ⇒ Object
Load a presentation from a directory of Markdown slide files.
Instance Method Summary collapse
-
#expected_time_at(index) ⇒ Object
Calculate the expected elapsed time for slides up to the given index.
-
#initialize(root = "slides", templates = Templates.for) ⇒ Presentation
constructor
Initialize a new presentation.
-
#reload ⇒ Object
Return a new Presentation with freshly loaded slides and a cleared template cache.
-
#slide_count ⇒ Object
The number of slides in the presentation.
- #The template resolver.=(templateresolver. = (value)) ⇒ Object
-
#total_duration ⇒ Object
The total expected duration of the presentation in seconds.
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.(root) @templates = templates @slides = end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
34 35 36 |
# File 'lib/presently/presentation.rb', line 34 def root @root end |
#slides ⇒ Object (readonly)
Returns the value of attribute slides.
37 38 39 |
# File 'lib/presently/presentation.rb', line 37 def @slides end |
#templates ⇒ Object (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
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 |
#reload ⇒ Object
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_count ⇒ Object
The number of slides in the presentation.
44 45 46 |
# File 'lib/presently/presentation.rb', line 44 def @slides.length end |
#The template resolver.=(templateresolver. = (value)) ⇒ Object
40 |
# File 'lib/presently/presentation.rb', line 40 attr :templates |
#total_duration ⇒ Object
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 |