class GhostWriter::IndexWriter::Base

Public Class Methods

new(document_index) click to toggle source
# File lib/ghost_writer/index_writer/base.rb, line 3
def initialize(document_index)
  @document_index = document_index
end

Public Instance Methods

write_file() click to toggle source
# File lib/ghost_writer/index_writer/base.rb, line 7
def write_file
  unless File.exist?(File.dirname(@document_index.basename))
    FileUtils.mkdir_p(File.dirname(@document_index.basename))
  end

  File.open("#{@document_index.basename}.#{extname}", "w") do |f|
    f.write template.result(@document_index.instance_eval { binding })
  end
end

Private Instance Methods

extname() click to toggle source
# File lib/ghost_writer/index_writer/base.rb, line 19
def extname
  raise NotImplementedError
end
template() click to toggle source
# File lib/ghost_writer/index_writer/base.rb, line 23
def template
  raise NotImplementedError
end