Class: RevealCK::PresentationDSL
- Inherits:
-
Object
- Object
- RevealCK::PresentationDSL
- 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
-
#author(author) ⇒ Object
readonly
Returns the value of attribute author.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#theme(theme) ⇒ Object
readonly
Rubocop doesn’t like trivial accessors, but docile breaks if trivial accessors are used.
-
#title(title) ⇒ Object
readonly
Returns the value of attribute title.
-
#transition(transition) ⇒ Object
readonly
Returns the value of attribute transition.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
- #contents_of(path) ⇒ Object
-
#initialize(args) ⇒ PresentationDSL
constructor
A new instance of PresentationDSL.
- #presentation(&block) ⇒ Object
-
#revealjs_config(key, value) ⇒ Object
rubocop:enable TrivialAccessors.
- #slide(template, variables = {}) ⇒ Object
Methods included from Retrieve
Constructor Details
#initialize(args) ⇒ PresentationDSL
Returns a new instance of PresentationDSL.
11 12 13 14 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 11 def initialize(args) @slides = [] @config = retrieve(:config, args) end |
Instance Attribute Details
#author(author) ⇒ Object (readonly)
Returns the value of attribute author.
8 9 10 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 8 def @author end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 9 def config @config end |
#theme(theme) ⇒ Object (readonly)
Rubocop doesn’t like trivial accessors, but docile breaks if trivial accessors are used. rubocop:disable TrivialAccessors
19 20 21 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 19 def theme @theme end |
#title(title) ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 8 def title @title end |
#transition(transition) ⇒ Object (readonly)
Returns the value of attribute transition.
8 9 10 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 8 def transition @transition end |
Class Method Details
.load(args) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 66 def self.load(args) file, config = retrieve(:file, args), retrieve(:config, args) builder = PresentationDSL.new config: config contents = File.open(file).read builder.instance_eval(contents) end |
Instance Method Details
#build ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 50 def build presentation = RevealCK::Presentation.new config: config presentation.theme = @theme if @theme presentation.transition = @transition if @transition presentation. = @author if @author presentation.title = @title if @title @slides.each { || presentation.add } presentation end |
#contents_of(path) ⇒ Object
46 47 48 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 46 def contents_of(path) File.open(path).read end |
#presentation(&block) ⇒ Object
62 63 64 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 62 def presentation(&block) Docile.dsl_eval(self, &block).build end |
#revealjs_config(key, value) ⇒ Object
rubocop:enable TrivialAccessors
36 37 38 |
# File 'lib/reveal-ck/presentation_dsl.rb', line 36 def revealjs_config(key, value) config.revealjs_config[key] = value end |