Class: Slippery::Presentation

Inherits:
Object
  • Object
show all
Includes:
Hexp
Defined in:
lib/slippery/presentation.rb

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(document, options = {}) ⇒ Presentation

Returns a new instance of Presentation.



10
11
12
13
# File 'lib/slippery/presentation.rb', line 10

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

Instance Method Details

#js_optionsObject



43
44
45
# File 'lib/slippery/presentation.rb', line 43

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

#processorsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/slippery/presentation.rb', line 15

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

#to_hexpObject



47
48
49
# File 'lib/slippery/presentation.rb', line 47

def to_hexp
  @document.process(*processors)
end