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, or initialize directly with an array of Slide instances.
Instance Attribute Summary collapse
-
#slides ⇒ Object
readonly
Returns the value of attribute slides.
-
#slides_root ⇒ Object
readonly
Returns the value of attribute slides_root.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
- #The directory slides were loaded from.(directoryslideswereloadedfrom.) ⇒ Object readonly
- #The ordered list of slides.(orderedlistofslides.) ⇒ Object readonly
Class Method Summary collapse
-
.load(slides_root = "slides", **options) ⇒ Object
Load a presentation from a directory of Markdown slide files.
-
.slides_from(slides_root) ⇒ Object
Load and sort slide files from a directory.
Instance Method Summary collapse
-
#expected_time_at(index) ⇒ Object
Calculate the expected elapsed time for slides up to the given index.
-
#initialize(slides = [], slides_root: nil, 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(slides = [], slides_root: nil, templates: Templates.for) ⇒ Presentation
Initialize a new presentation.
34 35 36 37 38 |
# File 'lib/presently/presentation.rb', line 34 def initialize( = [], slides_root: nil, templates: Templates.for) @slides = @slides_root = @templates = templates end |
Instance Attribute Details
#slides ⇒ Object (readonly)
Returns the value of attribute slides.
41 42 43 |
# File 'lib/presently/presentation.rb', line 41 def @slides end |
#slides_root ⇒ Object (readonly)
Returns the value of attribute slides_root.
44 45 46 |
# File 'lib/presently/presentation.rb', line 44 def @slides_root end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
47 48 49 |
# File 'lib/presently/presentation.rb', line 47 def templates @templates end |
#The directory slides were loaded from.(directoryslideswereloadedfrom.) ⇒ Object (readonly)
44 |
# File 'lib/presently/presentation.rb', line 44 attr :slides_root |
#The ordered list of slides.(orderedlistofslides.) ⇒ Object (readonly)
41 |
# File 'lib/presently/presentation.rb', line 41 attr :slides |
Class Method Details
.load(slides_root = "slides", **options) ⇒ Object
Load a presentation from a directory of Markdown slide files.
26 27 28 |
# File 'lib/presently/presentation.rb', line 26 def self.load( = "slides", **) new((), slides_root: , **) end |
Instance Method Details
#expected_time_at(index) ⇒ Object
Calculate the expected elapsed time for slides up to the given index.
64 65 66 |
# File 'lib/presently/presentation.rb', line 64 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. Only works if the presentation was created with load.
71 72 73 74 75 |
# File 'lib/presently/presentation.rb', line 71 def reload return self unless @slides_root self.class.new(self.class.(@slides_root), slides_root: @slides_root, templates: @templates.reload) end |
#slide_count ⇒ Object
The number of slides in the presentation.
51 52 53 |
# File 'lib/presently/presentation.rb', line 51 def @slides.length end |
#The template resolver.=(templateresolver. = (value)) ⇒ Object
47 |
# File 'lib/presently/presentation.rb', line 47 attr :templates |
#total_duration ⇒ Object
The total expected duration of the presentation in seconds.
57 58 59 |
# File 'lib/presently/presentation.rb', line 57 def total_duration @slides.sum(&:duration) end |