Class: TxtBook::KeynoteBuilder
- Inherits:
-
Object
- Object
- TxtBook::KeynoteBuilder
- Defined in:
- lib/txtbook.rb
Instance Attribute Summary collapse
-
#keynote_content ⇒ Object
Returns the value of attribute keynote_content.
-
#snippets ⇒ Object
Returns the value of attribute snippets.
-
#work_dir ⇒ Object
Returns the value of attribute work_dir.
Instance Method Summary collapse
- #gunzip(filename) ⇒ Object
-
#initialize(book_dir) ⇒ KeynoteBuilder
constructor
A new instance of KeynoteBuilder.
- #press ⇒ Object
- #rebind ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(book_dir) ⇒ KeynoteBuilder
Returns a new instance of KeynoteBuilder.
16 17 18 19 |
# File 'lib/txtbook.rb', line 16 def initialize(book_dir) @textbook = File.(book_dir) @work_dir = File.join(@textbook, "work") end |
Instance Attribute Details
#keynote_content ⇒ Object
Returns the value of attribute keynote_content.
14 15 16 |
# File 'lib/txtbook.rb', line 14 def keynote_content @keynote_content end |
#snippets ⇒ Object
Returns the value of attribute snippets.
14 15 16 |
# File 'lib/txtbook.rb', line 14 def snippets @snippets end |
#work_dir ⇒ Object
Returns the value of attribute work_dir.
14 15 16 |
# File 'lib/txtbook.rb', line 14 def work_dir @work_dir end |
Instance Method Details
#gunzip(filename) ⇒ Object
47 48 49 |
# File 'lib/txtbook.rb', line 47 def gunzip(filename) Kernel.system("gunzip --force #{filename}") end |
#press ⇒ Object
33 34 35 36 37 |
# File 'lib/txtbook.rb', line 33 def press @keynote_content.scan(/\$\{(.+?)\}/).each do |template| @keynote_content.gsub!("${#{template}}", IO.read("snippets/#{template}")) end end |
#rebind ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/txtbook.rb', line 39 def rebind Dir[File.join(@work_dir, "*.key")].each do |prez| File.open(File.join(@work_dir, prez, "index.apxl"), "w+") do |file| file.write @keynote_content end end end |
#unbind ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/txtbook.rb', line 21 def unbind FileUtils.mkdir_p @work_dir Dir[File.join(@textbook, "slides/*.key")].each do |prez| FileUtils.cp_r(prez, @work_dir) # DEBT Untested gunzip(File.join(@work_dir, File.basename(prez), "index.apxl.gz")) @keynote_content = IO.read(File.join(@work_dir, File.basename(prez), "index.apxl")) end end |