Sha256: d7f18e9975051c262e3e1c4106b8aa38c7d1229886b00223f4801c6714e907e0

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'malt/formats/abstract'
require 'malt/formats/html'
require 'malt/formats/pdf'

module Malt::Format

  # Plain text format. Plain text documents are uniqu in that they can
  # be transformed into any other type of document. For example, applying
  # to_html in text doesn't actually transform the source text in any way.
  # Rather it simply "informs" Malt to treat the text as HTML.
  #
  class Text < Abstract

    register('txt')

    #
    def txt(*)
      text
    end

    #
    def to_txt(*)
      self
    end

    #
    def method_missing(sym, *args, &block)
      if md = /^to_/.match(sym.to_s)
        type = md.post_match.to_sym
        opts = options.merge(:type=>type, :file=>refile(type))
        return Malt.text(text, opts)
      end
      super(sym, *args, &block)
    end

    # Returns an HTML object.
    #def to_html
    #  HTML.new(:text=>text,:file=>refile(:html))
    #end

    # Returns a PDF object.
    #def to_pdf
    #  PDF.new(:text=>text,:file=>refile(:pdf))
    #end

    private

      def render_engine
      end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
malt-0.3.0 lib/malt/formats/text.rb
malt-0.2.0 lib/malt/formats/text.rb
malt-0.1.1 lib/malt/formats/text.rb