Sha256: ae222b9c9fb1f767f3852581d29c053e4c0905e6e59534d8aa5ceef667b3e648

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

module Slippery
  class Presentation
    include Hexp

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

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

    def processors
      {
        impress_js: [
          Processors::HrToSections.new(H[:div, class: 'step']),
          Processors::ImpressJs::AddImpressJs.new(js_options),
          (Processors::ImpressJs::AutoOffsets.new unless @options.fetch(:manual_offsets, false)),
        ].compact,
        reveal_js: [
          Processors::HrToSections.new(H[:section]),
          Processors::RevealJs::AddRevealJs.new(js_options),
        ],
        fathom_js: [
          Processors::HrToSections.new(H[:div, class: 'slide']),
          Processors::JQuery.new(js_options),
          Processors::FathomJs.new(js_options),
        ],
        deck_js: [
          Processors::HrToSections.new(H[:section, class: 'slide']),
          Processors::JQuery.new(js_options),
          Processors::DeckJs.new(js_options),
        ],
        shower: [
          Processors::HrToSections.new(H[:section, class: 'slide']),
          Processors::Shower.new(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.4.2 lib/slippery/presentation.rb