Class: RevealCK::PresentationDSL

Inherits:
Object
  • Object
show all
Includes:
Retrieve
Defined in:
lib/reveal-ck/presentation_dsl.rb

Overview

Public: A PresentationDSL defines the DSL behind a presentation. It also knows how to load file containing the DSL.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Retrieve

included, #retrieve

Constructor Details

#initialize(args) ⇒ PresentationDSL

Returns a new instance of PresentationDSL.



10
11
12
13
# File 'lib/reveal-ck/presentation_dsl.rb', line 10

def initialize(args)
  @slides = []
  @config = retrieve(:config, args)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/reveal-ck/presentation_dsl.rb', line 8

def config
  @config
end

Class Method Details

.load(args) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/reveal-ck/presentation_dsl.rb', line 61

def self.load(args)
  file = retrieve(:file, args)
  config = retrieve(:config, args)
  builder = PresentationDSL.new config: config
  contents = File.open(file).read
  builder.instance_eval(contents)
end

Instance Method Details

#author(author) ⇒ Object



27
28
29
# File 'lib/reveal-ck/presentation_dsl.rb', line 27

def author(author)
  config.author = author
end

#buildObject



45
46
47
48
49
50
51
52
53
# File 'lib/reveal-ck/presentation_dsl.rb', line 45

def build
  presentation = RevealCK::Presentation.new config: config
  presentation.theme = @theme if @theme
  presentation.transition = @transition if @transition
  presentation.author = @author if @author
  presentation.title = @title if @title
  @slides.each { |slide| presentation.add slide }
  presentation
end

#contents_of(path) ⇒ Object



41
42
43
# File 'lib/reveal-ck/presentation_dsl.rb', line 41

def contents_of(path)
  File.open(path).read
end

#presentation(&block) ⇒ Object



57
58
59
# File 'lib/reveal-ck/presentation_dsl.rb', line 57

def presentation(&block)
  Docile.dsl_eval(self, &block).build
end

#revealjs_config(key, value) ⇒ Object



31
32
33
# File 'lib/reveal-ck/presentation_dsl.rb', line 31

def revealjs_config(key, value)
  config.revealjs_config[key] = value
end

#slide(template, variables = {}) ⇒ Object



35
36
37
38
39
# File 'lib/reveal-ck/presentation_dsl.rb', line 35

def slide(template, variables = {})
  variables[:template] = template
  variables[:config] = @config
  @slides << RevealCK::Slide.new(variables)
end

#theme(theme) ⇒ Object



15
16
17
# File 'lib/reveal-ck/presentation_dsl.rb', line 15

def theme(theme)
  config.theme = theme
end

#title(title) ⇒ Object



23
24
25
# File 'lib/reveal-ck/presentation_dsl.rb', line 23

def title(title)
  config.title = title
end

#transition(transition) ⇒ Object



19
20
21
# File 'lib/reveal-ck/presentation_dsl.rb', line 19

def transition(transition)
  config.transition = transition
end