Class: Caracal::Renderers::XmlRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/caracal/renderers/xml_renderer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ XmlRenderer

This method instantiates a new verison of this renderer.



34
35
36
37
38
39
40
# File 'lib/caracal/renderers/xml_renderer.rb', line 34

def initialize(doc)
  unless doc.is_a?(Caracal::Document)
    raise NoDocumentError, 'renderers must receive a reference to a valid Caracal document object.'
  end

  @document = doc
end

Instance Attribute Details

#documentObject (readonly)


Configuration




12
13
14
# File 'lib/caracal/renderers/xml_renderer.rb', line 12

def document
  @document
end

Class Method Details

.render(doc) ⇒ Object

This method produces xml output for the given document according to the rules of this renderer object.



22
23
24
25
# File 'lib/caracal/renderers/xml_renderer.rb', line 22

def self.render(doc)
  renderer = new(doc)
  renderer.to_xml
end

Instance Method Details

#to_xmlObject

This method converts data in the specified document to XML. A concrete implementation must be provided by the subclass.

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/caracal/renderers/xml_renderer.rb', line 45

def to_xml
  raise NotImplementedError, 'renderers must implement the method :to_xml.'
end