SOAPElement is not typed so it is not derived from NSDBase.
# File soap/baseData.rb, line 610
def self.decode(elename)
o = SOAPElement.new(elename)
o
end
# File soap/baseData.rb, line 615
def self.from_obj(obj, namespace = nil)
o = SOAPElement.new(nil)
case obj
when nil
o.text = nil
when Hash
obj.each do |elename, value|
if value.is_a?(Array)
value.each do |subvalue|
child = from_obj(subvalue, namespace)
child.elename = to_elename(elename, namespace)
o.add(child)
end
else
child = from_obj(value, namespace)
child.elename = to_elename(elename, namespace)
o.add(child)
end
end
else
o.text = obj.to_s
end
o
end
# File soap/baseData.rb, line 521
def initialize(elename, text = nil)
if !elename.is_a?(XSD::QName)
elename = XSD::QName.new(nil, elename)
end
@encodingstyle = LiteralNamespace
@elename = elename
@id = nil
@precedents = []
@root = false
@parent = nil
@position = nil
@extraattr = {}
@qualified = nil
@array = []
@data = []
@text = text
end
# File soap/baseData.rb, line 554
def [](idx)
if @array.include?(idx)
@data[@array.index(idx)]
else
nil
end
end
# File soap/baseData.rb, line 562
def []=(idx, data)
if @array.include?(idx)
data.parent = self if data.respond_to?(:parent=)
@data[@array.index(idx)] = data
else
add(data)
end
end
Element interfaces.
# File soap/baseData.rb, line 550
def add(value)
add_member(value.elename.name, value)
end
# File soap/baseData.rb, line 602
def each
idx = 0
while idx < @array.length
yield(@array[idx], @data[idx])
idx += 1
end
end
# File soap/baseData.rb, line 541
def inspect
sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename)
end
# File soap/baseData.rb, line 571
def key?(name)
@array.include?(name)
end
# File soap/baseData.rb, line 579
def to_obj
if members.empty?
@text
else
hash = {}
proptype = {}
each do |k, v|
value = v.respond_to?(:to_obj) ? v.to_obj : v.to_s
case proptype[k]
when :single
hash[k] = [hash[k], value]
proptype[k] = :multi
when :multi
hash[k] << value
else
hash[k] = value
proptype[k] = :single
end
end
hash
end
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 see Improve the docs, or visit Documenting-ruby.org.