class GhostWriter::Writer::Base
Public Class Methods
new(document, options = {})
click to toggle source
# File lib/ghost_writer/writer/base.rb, line 5 def initialize(document, options = {}) @document = document @overwrite = options[:overwrite] || false end
Public Instance Methods
write_file()
click to toggle source
# File lib/ghost_writer/writer/base.rb, line 10 def write_file unless File.exist?(File.dirname(@document.basename)) FileUtils.mkdir_p(File.dirname(@document.basename)) end mode = @overwrite ? "w" : "a" File.open("#{@document.basename}.#{extname}", mode) do |f| f.write template.result(@document.instance_eval { binding }) end end
Private Instance Methods
extname()
click to toggle source
# File lib/ghost_writer/writer/base.rb, line 23 def extname raise NotImplementedError end
template()
click to toggle source
# File lib/ghost_writer/writer/base.rb, line 27 def template raise NotImplementedError end