Module: XML::XMLRPC::Builder::Value

Defined in:
lib/xml/libxml/xmlrpc/builder.rb

Overview

Generates Values. This has several subclasses that map to core types which I will not document.

RTFS.

Defined Under Namespace

Modules: Array, Base64, Date, FalseClass, Fixnum, Float, Hash, NilClass, String, TrueClass

Class Method Summary collapse

Class Method Details

.generate(*args) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/xml/libxml/xmlrpc/builder.rb', line 150

def self.generate(*args)
    output = "<params>"
    args.each do |x|
        output += "<param>"
        output += self.generate_value(x)
        output += "</param>"
    end
    output += "</params>"

    return output
end

.generate_value(arg) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/xml/libxml/xmlrpc/builder.rb', line 162

def self.generate_value(arg)
    output = "<value>"

    # try the superclass if the class doesn't work (this isn't
    # perfect but is better than nothing)
    if arg.class == Builder::Base64
        output += Base64.generate(arg)
    elsif const_get(arg.class.to_s).respond_to? :generate
        output += const_get(arg.class.to_s).generate(arg)
    elsif const_get(arg.class.superclass.to_s).respond_to? :generate
        output += const_get(arg.class.superclass.to_s).generate(arg)
    else
        raise Builder::Error, "Type '#{arg.class}' is not supported by XML-RPC"
    end

    output += "</value>"

    return output
end