Class: RevealCK::SlidesHtmlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/reveal-ck/slides_html_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ SlidesHtmlBuilder

Returns a new instance of SlidesHtmlBuilder.



4
5
6
7
8
# File 'lib/reveal-ck/slides_html_builder.rb', line 4

def initialize(args)
  @input_file = args[:input_file]
  @presentation = args[:presentation]
  raise 'either :input_file or :presentation are required' unless @input_file || @presentation
end

Instance Method Details

#renderObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/reveal-ck/slides_html_builder.rb', line 10

def render
  if @input_file
    if @input_file.end_with? '.rb'
      presentation = RevealCK::Presentation.load @input_file
      presentation.content
    else
      template = TemplateProcessor.open @input_file
      template.output({}, {})
    end
  else
    @presentation.content
  end
end

#write_to(args) ⇒ Object



24
25
26
27
# File 'lib/reveal-ck/slides_html_builder.rb', line 24

def write_to(args)
  file = args[:file] || raise(':file is required')
  File.open(file, 'w') { |f| f << render }
end