Sha256: 979595103ea0f7544cd25254dcbdb44bf5c68c559ecdb905909c576679467228

Contents?: true

Size: 715 Bytes

Versions: 16

Compression:

Stored size: 715 Bytes

Contents

require "liquid"

module HtmlEmailCreator
  class Formatter
    @@DEFAULT = HtmlEmailCreator::Formatters::UnknownFormatter
    @@CONFIG = {}

    [
      HtmlEmailCreator::Formatters::Markdown,
      HtmlEmailCreator::Formatters::PlainTextEmail,
      HtmlEmailCreator::Formatters::HtmlEmail
    ].each do |klass|
      @@CONFIG[klass.id] = klass
    end
    
    def initialize(text, settings = HtmlEmailCreator.settings)
      @text = text
      @settings = settings
    end
    
    def find(format)
      klass = @@CONFIG[format.to_sym] || @@DEFAULT
      klass.send(:new, @text, @settings)
    end
        
    def find_by_filename(filename)
      find(File.extname(filename).split(".").last)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
html_email_creator-1.0.18 lib/html_email_creator/formatter.rb
html_email_creator-1.0.16 lib/html_email_creator/formatter.rb
html_email_creator-1.0.15 lib/html_email_creator/formatter.rb
html_email_creator-1.0.14 lib/html_email_creator/formatter.rb
html_email_creator-1.0.13 lib/html_email_creator/formatter.rb
html_email_creator-1.0.10 lib/html_email_creator/formatter.rb
html_email_creator-1.0.9 lib/html_email_creator/formatter.rb
html_email_creator-1.0.8 lib/html_email_creator/formatter.rb
html_email_creator-1.0.7 lib/html_email_creator/formatter.rb
html_email_creator-1.0.6 lib/html_email_creator/formatter.rb
html_email_creator-1.0.5 lib/html_email_creator/formatter.rb
html_email_creator-1.0.4 lib/html_email_creator/formatter.rb
html_email_creator-1.0.3 lib/html_email_creator/formatter.rb
html_email_creator-1.0.2 lib/html_email_creator/formatter.rb
html_email_creator-1.0.1 lib/html_email_creator/formatter.rb
html_email_creator-1.0.0 lib/html_email_creator/formatter.rb