Sha256: 5e549d668c58959d67b89c050fcbca5a2024deb7e209be67c15f1cdac8530ac1

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Slippery
  class Presentation
    include Hexp

    DEFAULT_OPTIONS = {
      type: :reveal_js,
      local: true,
      history: true
    }.freeze

    def initialize(document, options = {})
      @document = document
      @options = DEFAULT_OPTIONS.merge(options).freeze

      Assets::embed_locally if @options[:local]
    end

    def processors
      {
        impress_js: [
          Processors::HrToSections.new(H[:div, class: 'step']),
          Processors::ImpressJs::AddImpressJs.new(Assets::path_composer(@options[:local]), js_options),
          (Processors::ImpressJs::AutoOffsets.new unless @options.fetch(:manual_offsets, false)),
        ].compact,
        reveal_js: [
          Processors::HrToSections.new(H[:section]),
          Processors::RevealJs::AddRevealJs.new(Assets::path_composer(@options[:local]), js_options),
        ]
      }[@options[:type]]
    end

    def js_options
      @options.reject { |key, _| [:type].include? key }
    end

    def to_hexp
      @document.process(*processors)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slippery-0.1.0 lib/slippery/presentation.rb