Module: XML::XMLRPC::Parser::ValueParser
- Defined in:
- lib/xml/libxml/xmlrpc/parser.rb
Overview
Parse values from a XML::Node::Set or Array of XML::Node objects.
May be called recursively by ValueParser::Array or ValueParser::Struct.
Defined Under Namespace
Class Method Summary collapse
Class Method Details
.parse(values) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/xml/libxml/xmlrpc/parser.rb', line 161 def self.parse(values) parsed_params = [] values.each do |param_value_node| value = nil if param_value_node param_value_node.each_child do |type| value = case type.name.downcase when /^(?:i4|int)$/ type.content.strip.to_i when 'string' type.content when 'boolean' if type.content.strip.to_i == 1 true else false end when 'double' type.content.strip.to_f when 'datetime.iso8601' # Looks like this: 19980717T14:08:55 DateTime.strptime(type.content.strip, "%Y%m%dT%T") when 'base64' Base64.decode64(type.content.strip) when 'struct' Parser::ValueParser::Struct.parse(type) when 'array' Parser::ValueParser::Array.parse(type) end break if value end end parsed_params.push value end return parsed_params end |