Sha256: 35506818df19e651b25eb41c80acf21288fbe2e5a7f5c6b0da3ea1441e349dee

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

require 'active_support/core_ext/string'

class GhostWriter::Writer
  autoload "Markdown", "ghost_writer/writer/markdown"
  autoload "Rst", "ghost_writer/writer/rst"

  def initialize(document, options = {})
    @document  = document
    @format    = options.delete(:format) || :markdown
    @options   = options
  end

  def write_file
    format_class = lookup_format_class
    format = format_class.new(@document, @options)
    format.write_file
  end

  private

  def lookup_format_class
    case @format
    when Class
      @format
    when String, Symbol
      "GhostWriter::Writer::#{@format.to_s.classify}".constantize
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ghost_writer-0.5.0 lib/ghost_writer/writer.rb
ghost_writer-0.4.2 lib/ghost_writer/writer.rb