Class: SlideEmUp::Presentation
- Inherits:
-
Object
- Object
- SlideEmUp::Presentation
- Defined in:
- lib/slide-em-up/presentation.rb
Defined Under Namespace
Classes: Meta, Section, Slide, Theme
Instance Attribute Summary collapse
-
#common ⇒ Object
Returns the value of attribute common.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#parts ⇒ Object
Returns the value of attribute parts.
-
#theme ⇒ Object
Returns the value of attribute theme.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(dir) ⇒ Presentation
constructor
A new instance of Presentation.
- #nb_slides ⇒ Object
- #path_for_asset(asset) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Presentation
Returns a new instance of Presentation.
21 22 23 24 25 26 27 28 29 |
# File 'lib/slide-em-up/presentation.rb', line 21 def initialize(dir) infos = extract_normal_infos(dir) || extract_infos_from_showoff(dir) || {} infos = { "title" => "No title", "theme" => "shower", "duration" => 60 }.merge(infos) @meta = (infos["title"], dir, infos["author"], infos["duration"]) @theme = build_theme(infos["theme"]) @common = build_theme("common") @parts = infos["sections"] || raise(Exception, "check your presentation.json or showoff.json file") @parts = Hash[@parts.zip @parts] if Array === @parts end |
Instance Attribute Details
#common ⇒ Object
Returns the value of attribute common.
19 20 21 |
# File 'lib/slide-em-up/presentation.rb', line 19 def common @common end |
#meta ⇒ Object
Returns the value of attribute meta.
19 20 21 |
# File 'lib/slide-em-up/presentation.rb', line 19 def @meta end |
#parts ⇒ Object
Returns the value of attribute parts.
19 20 21 |
# File 'lib/slide-em-up/presentation.rb', line 19 def parts @parts end |
#theme ⇒ Object
Returns the value of attribute theme.
19 20 21 |
# File 'lib/slide-em-up/presentation.rb', line 19 def theme @theme end |
Instance Method Details
#html ⇒ Object
31 32 33 34 |
# File 'lib/slide-em-up/presentation.rb', line 31 def html str = File.read("#{theme.dir}/index.erb") Erubis::Eruby.new(str).result(:meta => , :theme => theme, :sections => sections) end |
#nb_slides ⇒ Object
43 44 45 46 47 48 |
# File 'lib/slide-em-up/presentation.rb', line 43 def @parts.inject(0) do |nb,(dir,title)| raw = Dir["#{.dir}/#{dir}/**/*.md"].map { |f| File.read(f) }.join("\n\n") nb += raw.split(/!SLIDE */).length end end |
#path_for_asset(asset) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/slide-em-up/presentation.rb', line 36 def path_for_asset(asset) Dir[ "#{.dir}#{asset}"].first || Dir[ "#{theme.dir}#{asset}"].first || Dir[ "#{common.dir}#{asset}"].first || Dir["#{.dir}/**#{asset}"].first end |