Class: Slidr::Html
- Inherits:
-
Object
- Object
- Slidr::Html
- Defined in:
- lib/slidr/html.rb
Instance Method Summary collapse
- #add(command) ⇒ Object
- #generate ⇒ Object
-
#initialize(args) ⇒ Html
constructor
A new instance of Html.
Constructor Details
#initialize(args) ⇒ Html
Returns a new instance of Html.
5 6 7 8 9 10 11 |
# File 'lib/slidr/html.rb', line 5 def initialize(args) @html_path = args[:html] @name = args[:name] @path = args[:path] @draft = args[:draft] @commands = [] end |
Instance Method Details
#add(command) ⇒ Object
13 14 15 16 |
# File 'lib/slidr/html.rb', line 13 def add(command) @commands << command self end |
#generate ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/slidr/html.rb', line 18 def generate unless File.directory?(@path) FileUtils.mkdir_p(@path) end FileUtils.cp(@inserts[:remark], @path) FileUtils.cp(@inserts[:structure], @path) FileUtils.cp_r(Dir["#{ @inserts[:layout] }/*"], @path) content = File.read(@html_path) content.gsub!('{{TITLE}}', @inserts[:title]) content.gsub!('{{MARKDOWN}}', @inserts[:slides]) content.gsub!('{{REMARK_PATH}}', @inserts[:remark][@inserts[:remark].rindex('/')+1..-1]) content.gsub!('{{STRUCTURE_PATH}}', @inserts[:structure][@inserts[:structure].rindex('/')+1..-1]) content.gsub!('{{SCRIPT_INIT}}', @inserts[:script]) File.open("#{ @path }/#{ @name }", "w") do |file| file.puts content end end |