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.
17 18 19 20 |
# File 'lib/txtbook.rb', line 17 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.
15 16 17 |
# File 'lib/txtbook.rb', line 15 def keynote_content @keynote_content end |
#snippets ⇒ Object
Returns the value of attribute snippets.
15 16 17 |
# File 'lib/txtbook.rb', line 15 def snippets @snippets end |
#work_dir ⇒ Object
Returns the value of attribute work_dir.
15 16 17 |
# File 'lib/txtbook.rb', line 15 def work_dir @work_dir end |
Instance Method Details
#gunzip(filename) ⇒ Object
48 49 50 |
# File 'lib/txtbook.rb', line 48 def gunzip(filename) Kernel.system("gunzip --force #{filename}") end |
#press ⇒ Object
34 35 36 37 38 |
# File 'lib/txtbook.rb', line 34 def press @keynote_content.scan(/\$\{(.+?)\}/).each do |template| @keynote_content.gsub!("${#{template}}", IO.read("snippets/#{template}")) end end |
#rebind ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/txtbook.rb', line 40 def rebind Dir[File.join(@work_dir, "*.key")].each do |preso| File.open(File.join(@work_dir, File.basename(preso), "index.apxl"), "w+") do |file| file.write @keynote_content end end end |
#unbind ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/txtbook.rb', line 22 def unbind FileUtils.mkdir_p @work_dir Dir[File.join(@textbook, "slides/*.key")].each do |preso| copy_to_working_dir(preso) gunzip(File.join(@work_dir, File.basename(preso), "index.apxl.gz")) content_file = File.join(@work_dir, File.basename(preso), "index.apxl") @keynote_content = IO.read(content_file) end end |