Class: XMLRPC::XMLWriter::Simple

Inherits:
Abstract
  • Object
show all
Defined in:
lib/xmlrpc/create.rb

Instance Method Summary collapse

Methods inherited from Abstract

#ele, #tag

Instance Method Details

#document(*params) ⇒ Object



32
33
34
# File 'lib/xmlrpc/create.rb', line 32

def document(*params)
  params.join("")
end

#document_to_str(doc) ⇒ Object



28
29
30
# File 'lib/xmlrpc/create.rb', line 28

def document_to_str(doc)
  doc
end

#element(name, attrs, *children) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/xmlrpc/create.rb', line 40

def element(name, attrs, *children)
  raise "attributes not yet implemented" unless attrs.nil?
  if children.empty?
    "<#{name}/>"
  else
    "<#{name}>" + children.join("") + "</#{name}>"
  end
end

#pi(name, *params) ⇒ Object



36
37
38
# File 'lib/xmlrpc/create.rb', line 36

def pi(name, *params)
  "<?#{name} " + params.join(" ") + " ?>"
end

#text(txt) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/xmlrpc/create.rb', line 49

def text(txt)
  cleaned = txt.dup
  cleaned.gsub!(/&/, '&amp;')
  cleaned.gsub!(/</, '&lt;')
  cleaned.gsub!(/>/, '&gt;')
  cleaned
end