class GhostWriter::IndexWriter

Public Class Methods

new(document_index, options = {}) click to toggle source
# File lib/ghost_writer/index_writer.rb, line 7
def initialize(document_index, options = {})
  @document_index  = document_index
  @format          = options.delete(:format) || :markdown
end

Public Instance Methods

write_file() click to toggle source
# File lib/ghost_writer/index_writer.rb, line 12
def write_file
  format_class = lookup_format_class
  format = format_class.new(@document_index)
  format.write_file
end

Private Instance Methods

lookup_format_class() click to toggle source
# File lib/ghost_writer/index_writer.rb, line 20
def lookup_format_class
  case @format
  when Class
    @format
  when String, Symbol
    "GhostWriter::IndexWriter::#{@format.to_s.classify}".constantize
  end
end