Class: Malt::Format::Text

Inherits:
Abstract show all
Defined in:
lib/malt/formats/text.rb

Overview

Plain text format. Plain text documents are unique 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.

Instance Attribute Summary

Attributes inherited from Abstract

#options

Instance Method Summary collapse

Methods inherited from Abstract

#default, #engine, engine, extensions, #extensions, #file, file_extension, #file_read, #file_type, #parse_type_from_data, #refile, register, #render, #render_into, #rendering_parameters, #scope_vs_data, #subtype, #text, #to, #to_default, #to_s, #type, #with, #with!

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object


27
28
29
30
31
32
33
34
# File 'lib/malt/formats/text.rb', line 27

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

Instance Method Details

#to_txtObject


22
23
24
# File 'lib/malt/formats/text.rb', line 22

def to_txt(*)
  self
end

#txtObject


17
18
19
# File 'lib/malt/formats/text.rb', line 17

def txt(*)
  text
end