module Canon
def self.format(content, format = :xml)
-
(String)- The formatted content
Parameters:
-
format(Symbol) -- The format type (:xml, :yaml, :json) -
content(String) -- The content to format
def self.format(content, format = :xml) get_formatter(format).format(content) end
def self.get_formatter(format)
def self.get_formatter(format) case format.to_sym when :xml Formatters::XmlFormatter when :yaml Formatters::YamlFormatter when :json Formatters::JsonFormatter when :html Formatters::HtmlFormatter when :html4 Formatters::Html4Formatter when :html5 Formatters::Html5Formatter else raise Error, "Unsupported format: #{format}" end end
def self.parse(content, format = :xml)
-
(Object)- The parsed content
Parameters:
-
format(Symbol) -- The format type (:xml, :yaml, :json) -
content(String) -- The content to parse
def self.parse(content, format = :xml) get_formatter(format).parse(content) end