Class: SOAP::SOAPStruct

Inherits:
XSD::NSDBase show all
Includes:
Enumerable, SOAPCompoundtype
Defined in:
lib/soap/baseData.rb

Overview

Compound datatypes.

Direct Known Subclasses

RPC::SOAPMethod, SOAPBody, SOAPFault, SOAPHeader

Constant Summary

Constants included from SOAP

AttrActor, AttrActorName, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrMustUnderstand, AttrMustUnderstandName, AttrOffset, AttrOffsetName, AttrPosition, AttrPositionName, AttrRoot, AttrRootName, Base64Literal, Charset, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NS, NextActor, PropertyName, RPCRouter, RPCServerException, RPCUtils, SOAPNamespaceTag, SOAPProxy, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag

Instance Attribute Summary

Attributes included from SOAPCompoundtype

#qualified

Attributes included from SOAPType

#definedtype, #elename, #encodingstyle, #extraattr, #id, #parent, #position, #precedents, #root

Attributes inherited from XSD::NSDBase

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#inject

Methods included from SOAPType

#inspect, #rootnode

Methods inherited from XSD::NSDBase

inherited, #init, types

Constructor Details

#initialize(type = nil) ⇒ SOAPStruct

Returns a new instance of SOAPStruct.


462
463
464
465
466
467
# File 'lib/soap/baseData.rb', line 462

def initialize(type = nil)
  super()
  @type = type || XSD::QName::EMPTY
  @array = []
  @data = []
end

Class Method Details

.decode(elename, type) ⇒ Object


552
553
554
555
556
# File 'lib/soap/baseData.rb', line 552

def self.decode(elename, type)
  s = SOAPStruct.new(type)
  s.elename = elename
  s
end

Instance Method Details

#[](idx) ⇒ Object


481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/soap/baseData.rb', line 481

def [](idx)
  if idx.is_a?(Range)
    @data[idx]
  elsif idx.is_a?(Integer)
    if (idx > @array.size)
      raise ArrayIndexOutOfBoundsError.new('In ' << @type.name)
    end
    @data[idx]
  else
    if @array.include?(idx)
	@data[@array.index(idx)]
    else
	nil
    end
  end
end

#[]=(idx, data) ⇒ Object


498
499
500
501
502
503
504
505
# File 'lib/soap/baseData.rb', line 498

def []=(idx, data)
  if @array.include?(idx)
    data.parent = self if data.respond_to?(:parent=)
    @data[@array.index(idx)] = data
  else
    add(idx, data)
  end
end

#add(name, value) ⇒ Object


477
478
479
# File 'lib/soap/baseData.rb', line 477

def add(name, value)
  add_member(name, value)
end

#eachObject


538
539
540
541
542
543
544
# File 'lib/soap/baseData.rb', line 538

def each
  idx = 0
  while idx < @array.length
    yield(@array[idx], @data[idx])
    idx += 1
  end
end

#have_memberObject


515
516
517
# File 'lib/soap/baseData.rb', line 515

def have_member
  !@array.empty?
end

#key?(name) ⇒ Boolean

Returns:

  • (Boolean)

507
508
509
# File 'lib/soap/baseData.rb', line 507

def key?(name)
  @array.include?(name)
end

#membersObject


511
512
513
# File 'lib/soap/baseData.rb', line 511

def members
  @array
end

#replaceObject


546
547
548
549
550
# File 'lib/soap/baseData.rb', line 546

def replace
  members.each do |member|
    self[member] = yield(self[member])
  end
end

#to_objObject


519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/soap/baseData.rb', line 519

def to_obj
  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

#to_sObject


469
470
471
472
473
474
475
# File 'lib/soap/baseData.rb', line 469

def to_s()
  str = ''
  self.each do |key, data|
    str << "#{key}: #{data}\n"
  end
  str
end