Class SOAP::SOAPStruct
In: lib/soap/baseData.rb
Parent: XSD::NSDBase

Compound datatypes.

Methods

[]   []=   add   add_member   decode   each   key?   members   new   replace   to_obj   to_s  

Included Modules

SOAPCompoundtype Enumerable

Public Class methods

[Source]

     # File lib/soap/baseData.rb, line 486
486:   def self.decode(elename, type)
487:     s = SOAPStruct.new(type)
488:     s.elename = elename
489:     s
490:   end

[Source]

     # File lib/soap/baseData.rb, line 400
400:   def initialize(type = nil)
401:     super()
402:     @type = type || XSD::QName::EMPTY
403:     @array = []
404:     @data = []
405:   end

Public Instance methods

[Source]

     # File lib/soap/baseData.rb, line 419
419:   def [](idx)
420:     if idx.is_a?(Range)
421:       @data[idx]
422:     elsif idx.is_a?(Integer)
423:       if (idx > @array.size)
424:         raise ArrayIndexOutOfBoundsError.new('In ' << @type.name)
425:       end
426:       @data[idx]
427:     else
428:       if @array.include?(idx)
429:         @data[@array.index(idx)]
430:       else
431:         nil
432:       end
433:     end
434:   end

[Source]

     # File lib/soap/baseData.rb, line 436
436:   def []=(idx, data)
437:     if @array.include?(idx)
438:       data.parent = self if data.respond_to?(:parent=)
439:       @data[@array.index(idx)] = data
440:     else
441:       add(idx, data)
442:     end
443:   end

[Source]

     # File lib/soap/baseData.rb, line 415
415:   def add(name, value)
416:     add_member(name, value)
417:   end

[Source]

     # File lib/soap/baseData.rb, line 472
472:   def each
473:     idx = 0
474:     while idx < @array.length
475:       yield(@array[idx], @data[idx])
476:       idx += 1
477:     end
478:   end

[Source]

     # File lib/soap/baseData.rb, line 445
445:   def key?(name)
446:     @array.include?(name)
447:   end

[Source]

     # File lib/soap/baseData.rb, line 449
449:   def members
450:     @array
451:   end

[Source]

     # File lib/soap/baseData.rb, line 480
480:   def replace
481:     members.each do |member|
482:       self[member] = yield(self[member])
483:     end
484:   end

[Source]

     # File lib/soap/baseData.rb, line 453
453:   def to_obj
454:     hash = {}
455:     proptype = {}
456:     each do |k, v|
457:       value = v.respond_to?(:to_obj) ? v.to_obj : v.to_s
458:       case proptype[k]
459:       when :single
460:         hash[k] = [hash[k], value]
461:         proptype[k] = :multi
462:       when :multi
463:         hash[k] << value
464:       else
465:         hash[k] = value
466:         proptype[k] = :single
467:       end
468:     end
469:     hash
470:   end

[Source]

     # File lib/soap/baseData.rb, line 407
407:   def to_s()
408:     str = ''
409:     self.each do |key, data|
410:       str << "#{key}: #{data}\n"
411:     end
412:     str
413:   end

Private Instance methods

[Source]

     # File lib/soap/baseData.rb, line 494
494:   def add_member(name, value = nil)
495:     value = SOAPNil.new() if value.nil?
496:     @array.push(name)
497:     value.elename = value.elename.dup_name(name)
498:     @data.push(value)
499:     value.parent = self if value.respond_to?(:parent=)
500:     value
501:   end

[Validate]