Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • xmlrpc/create.rb

Parent

XMLRPC::Create

Public Class Methods

new(xml_writer = nil) click to toggle source
 
               # File xmlrpc/create.rb, line 105
def initialize(xml_writer = nil)
  @writer = xml_writer || Config::DEFAULT_WRITER.new
end
            

Public Instance Methods

methodCall(name, *params) click to toggle source
 
               # File xmlrpc/create.rb, line 110
def methodCall(name, *params)
  name = name.to_s

  if name !~ /[a-zA-Z0-9_.:\/]+/
    raise ArgumentError, "Wrong XML-RPC method-name"
  end

  parameter = params.collect do |param|
    @writer.ele("param", conv2value(param))
  end

  tree = @writer.document(
           @writer.pi("xml", 'version="1.0"'),
           @writer.ele("methodCall",
             @writer.tag("methodName", name),
             @writer.ele("params", *parameter)
           )
         )

  @writer.document_to_str(tree) + "\n"
end
            
methodResponse(is_ret, *params) click to toggle source

generates a XML-RPC methodResponse document

if is_ret == false then the params array must contain only one element, which is a structure of a fault return-value.

if is_ret == true then a normal return-value of all the given params is created.

 
               # File xmlrpc/create.rb, line 144
def methodResponse(is_ret, *params)

  if is_ret
    resp = params.collect do |param|
      @writer.ele("param", conv2value(param))
    end

    resp = [@writer.ele("params", *resp)]
  else
    if params.size != 1 or params[0] === XMLRPC::FaultException
      raise ArgumentError, "no valid fault-structure given"
    end
    resp = @writer.ele("fault", conv2value(params[0].to_h))
  end


  tree = @writer.document(
           @writer.pi("xml", 'version="1.0"'),
           @writer.ele("methodResponse", resp)
         )

  @writer.document_to_str(tree) + "\n"
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus