Class: SOAP::SOAPArray
Constant Summary
Constants included
from SOAP
AttrActor, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrMustUnderstand, AttrMustUnderstandName, AttrOffset, AttrOffsetName, AttrPosition, AttrPositionName, AttrRoot, AttrRootName, Base64Literal, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NextActor, PropertyName, SOAPNamespaceTag, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag
Instance Attribute Summary collapse
Attributes included from SOAPType
#definedtype, #elename, #encodingstyle, #extraattr, #id, #parent, #precedents, #root
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Enumerable
#inject
Methods included from SOAPType
#inspect, #rootnode
Constructor Details
#initialize(type = nil, rank = 1, arytype = nil) ⇒ SOAPArray
Returns a new instance of SOAPArray.
706
707
708
709
710
711
712
713
714
715
716
717
|
# File 'lib/soap/baseData.rb', line 706
def initialize(type = nil, rank = 1, arytype = nil)
super()
@type = type || ValueArrayName
@rank = rank
@data = Array.new
@sparse = false
@offset = Array.new(rank, 0)
@size = Array.new(rank, 0)
@size_fixed = false
@position = nil
@arytype = arytype
end
|
Instance Attribute Details
Returns the value of attribute arytype
704
705
706
|
# File 'lib/soap/baseData.rb', line 704
def arytype
@arytype
end
|
Returns the value of attribute offset
702
703
704
|
# File 'lib/soap/baseData.rb', line 702
def offset
@offset
end
|
Returns the value of attribute rank
702
703
704
|
# File 'lib/soap/baseData.rb', line 702
def rank
@rank
end
|
Returns the value of attribute size
703
704
705
|
# File 'lib/soap/baseData.rb', line 703
def size
@size
end
|
#size_fixed ⇒ Object
Returns the value of attribute size_fixed
703
704
705
|
# File 'lib/soap/baseData.rb', line 703
def size_fixed
@size_fixed
end
|
Returns the value of attribute sparse
700
701
702
|
# File 'lib/soap/baseData.rb', line 700
def sparse
@sparse
end
|
Class Method Details
.decode(elename, type, arytype) ⇒ Object
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
|
# File 'lib/soap/baseData.rb', line 902
def self.decode(elename, type, arytype)
typestr, nofary = parse_type(arytype.name)
rank = nofary.count(',') + 1
plain_arytype = XSD::QName.new(arytype.namespace, typestr)
o = SOAPArray.new(type, rank, plain_arytype)
size = []
nofary.split(',').each do |s|
if s.empty?
size.clear
break
else
size << s.to_i
end
end
unless size.empty?
o.size = size
o.size_fixed = true
end
o.elename = elename
o
end
|
Instance Method Details
#[](*idxary) ⇒ Object
728
729
730
731
732
733
734
|
# File 'lib/soap/baseData.rb', line 728
def [](*idxary)
if idxary.size != @rank
raise ArgumentError.new("given #{idxary.size} params does not match rank: #{@rank}")
end
retrieve(idxary)
end
|
#[]=(*idxary) ⇒ Object
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
# File 'lib/soap/baseData.rb', line 736
def []=(*idxary)
value = idxary.slice!(-1)
if idxary.size != @rank
raise ArgumentError.new("given #{idxary.size} params(#{idxary})" +
" does not match rank: #{@rank}")
end
idx = 0
while idx < idxary.size
if idxary[idx] + 1 > @size[idx]
@size[idx] = idxary[idx] + 1
end
idx += 1
end
data = retrieve(idxary[0, idxary.size - 1])
data[idxary.last] = value
if value.is_a?(SOAPType)
value.elename = ITEM_NAME
unless @type.name
@type = XSD::QName.new(value.type.namespace,
SOAPArray.create_arytype(value.type.name, @rank))
end
value.type ||= @type
end
@offset = idxary
value.parent = self if value.respond_to?(:parent=)
offsetnext
end
|
#add(value) ⇒ Object
724
725
726
|
# File 'lib/soap/baseData.rb', line 724
def add(value)
self[*(@offset)] = value
end
|
#deep_map(ary, &block) ⇒ Object
786
787
788
789
790
791
792
793
794
795
796
|
# File 'lib/soap/baseData.rb', line 786
def deep_map(ary, &block)
ary.collect do |ele|
if ele.is_a?(Array)
deep_map(ele, &block)
else
new_obj = block.call(ele)
new_obj.elename = ITEM_NAME
new_obj
end
end
end
|
770
771
772
773
774
|
# File 'lib/soap/baseData.rb', line 770
def each
@data.each do |data|
yield(data)
end
end
|
#include?(var) ⇒ Boolean
798
799
800
801
802
803
804
805
|
# File 'lib/soap/baseData.rb', line 798
def include?(var)
traverse_data(@data) do |v, *rank|
if v.is_a?(SOAPBasetype) && v.data == var
return true
end
end
false
end
|
838
839
840
|
# File 'lib/soap/baseData.rb', line 838
def position
@position
end
|
780
781
782
783
784
|
# File 'lib/soap/baseData.rb', line 780
def replace
@data = deep_map(@data) do |ele|
yield(ele)
end
end
|
#soap2array(ary) ⇒ Object
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
|
# File 'lib/soap/baseData.rb', line 817
def soap2array(ary)
traverse_data(@data) do |v, *position|
iteary = ary
rank = 1
while rank < position.size
idx = position[rank - 1]
if iteary[idx].nil?
iteary = iteary[idx] = Array.new
else
iteary = iteary[idx]
end
rank += 1
end
if block_given?
iteary[position.last] = yield(v)
else
iteary[position.last] = v
end
end
end
|
776
777
778
|
# File 'lib/soap/baseData.rb', line 776
def to_a
@data.dup
end
|
807
808
809
810
811
812
813
814
815
|
# File 'lib/soap/baseData.rb', line 807
def traverse
traverse_data(@data) do |v, *rank|
unless @sparse
yield(v)
else
yield(v, *rank) if v && !v.is_a?(SOAPNil)
end
end
end
|