Class: Representative::Xml

Inherits:
AbstractXml show all
Defined in:
lib/representative/xml.rb

Overview

Easily generate XML while traversing an object-graph.

Instance Method Summary collapse

Methods inherited from AbstractXml

#element, #empty, #list_of

Methods inherited from Base

#current_subject, #representing

Constructor Details

#initialize(xml_builder, subject = nil, options = {}) {|_self| ... } ⇒ Xml

Create an XML-generating Representative. The first argument should be an instance of Builder::XmlMarkup (or something that implements it’s interface). The second argument if any, is the initial #subject of representation.

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
20
# File 'lib/representative/xml.rb', line 16

def initialize(xml_builder, subject = nil, options = {})
  @xml = xml_builder
  super(subject, options)
  yield self if block_given?
end

Instance Method Details

#comment(text) ⇒ Object

Generate a comment



24
25
26
# File 'lib/representative/xml.rb', line 24

def comment(text)
  @xml.comment!(text)
end