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
15
16
# File 'lib/slippery/presentation.rb', line 11

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

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

Instance Method Details

#js_optionsObject



32
33
34
# File 'lib/slippery/presentation.rb', line 32

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

#processorsObject



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

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

#to_hexpObject



36
37
38
# File 'lib/slippery/presentation.rb', line 36

def to_hexp
  @document.process(*processors)
end