Class: Slippery::Presentation

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Presentation.



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

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

Instance Method Details

#js_optionsObject



30
31
32
# File 'lib/slippery/presentation.rb', line 30

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

#processorsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/slippery/presentation.rb', line 16

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),
    ]
  }[@options[:type]]
end

#to_hexpObject



34
35
36
# File 'lib/slippery/presentation.rb', line 34

def to_hexp
  @document.process(*processors)
end