Method: Kramdown::Document#method_missing

Defined in:
lib/kramdown/document.rb

#method_missing(id, *attr, &block) ⇒ Object

Check if a method is invoked that begins with to_ and if so, try to instantiate a converter class (i.e. a class in the Kramdown::Converter module) and use it for converting the document.

For example, to_html would instantiate the Kramdown::Converter::Html class.



100
101
102
103
104
105
106
107
108
# File 'lib/kramdown/document.rb', line 100

def method_missing(id, *attr, &block)
  if id.to_s =~ /^to_(\w+)$/ && (name = $1[0..0].upcase + $1[1..-1]) && Converter.const_defined?(name)
    output, warnings = Converter.const_get(name).convert(@root, @options)
    @warnings.concat(warnings)
    output
  else
    super
  end
end