Sha256: 304dfc0f0d09b8612260eeca6a036baa224a203c080c16a165696c90d4ed4e10

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

require 'forwardable'

module RevealCK
  #
  # Public: A Presentation is slide html and metadata. Access html via
  # #html. Access metadata via theme, title, author, transition.
  #
  class Presentation
    include Retrieve
    extend Forwardable
    %i[author title transition theme].each do |name|
      def_delegators :@config, name, "#{name}=".to_sym
    end

    def revealjs_config
      @config.revealjs_config
    end

    attr_accessor :html, :config

    def initialize(args)
      @html = ''
      @config = retrieve(:config, args)
    end

    def add(content)
      @html << content.html
    end

    def self.from_template(args)
      file = retrieve(:file, args)
      config = retrieve(:config, args)
      presentation = Presentation.new config: config
      template = Templates::Processor.open(file: file, config: config)
      presentation.html = template.output
      presentation
    end

    def self.from_dsl(args)
      file = retrieve(:file, args)
      config = retrieve(:config, args)
      RevealCK::PresentationDSL.load file: file, config: config
    end

    def self.load(args)
      file = retrieve(:file, args)
      config = retrieve(:config, args)
      if file.end_with? '.rb'
        Presentation.from_dsl file: file, config: config
      else
        Presentation.from_template file: file, config: config
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reveal-ck-4.0.0 lib/reveal-ck/presentation.rb
reveal-ck-3.9.2 lib/reveal-ck/presentation.rb
reveal-ck-3.9.1 lib/reveal-ck/presentation.rb
reveal-ck-3.9.0 lib/reveal-ck/presentation.rb
reveal-ck-3.8.1 lib/reveal-ck/presentation.rb
reveal-ck-3.8.0 lib/reveal-ck/presentation.rb
reveal-ck-3.7.0 lib/reveal-ck/presentation.rb
reveal-ck-3.6.0 lib/reveal-ck/presentation.rb