Class: SOAP::SOAPArray
- Inherits:
-
XSD::NSDBase
- Object
- XSD::NSDBase
- SOAP::SOAPArray
show all
- Includes:
- Enumerable, SOAPCompoundtype
- Defined in:
- lib/soap4r_19_patch/soap/baseData.rb
Constant Summary
Constants included
from SOAP
SOAPGenerator
Instance Attribute Summary collapse
#qualified
Attributes included from SOAPType
#definedtype, #elename, #encodingstyle, #extraattr, #id, #parent, #precedents, #root
Instance Method Summary
collapse
Methods included from SOAPType
#inspect, #rootnode
Constructor Details
#initialize(type = nil, rank = 1, arytype = nil) ⇒ SOAPArray
Returns a new instance of SOAPArray.
865
866
867
868
869
870
871
872
873
874
875
876
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 865
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
#arytype ⇒ Object
Returns the value of attribute arytype.
863
864
865
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 863
def arytype
@arytype
end
|
#offset ⇒ Object
Returns the value of attribute offset.
861
862
863
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 861
def offset
@offset
end
|
#rank ⇒ Object
Returns the value of attribute rank.
861
862
863
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 861
def rank
@rank
end
|
#size ⇒ Object
Returns the value of attribute size.
862
863
864
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 862
def size
@size
end
|
#size_fixed ⇒ Object
Returns the value of attribute size_fixed.
862
863
864
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 862
def size_fixed
@size_fixed
end
|
#sparse ⇒ Object
Returns the value of attribute sparse.
859
860
861
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 859
def sparse
@sparse
end
|
Instance Method Details
#[](*idxary) ⇒ Object
891
892
893
894
895
896
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 891
def [](*idxary)
if idxary.size != @rank
raise ArgumentError.new("given #{idxary.size} params does not match rank: #{@rank}")
end
retrieve(idxary)
end
|
#[]=(*idxary) ⇒ Object
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 898
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
883
884
885
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 883
def add(value)
self[*(@offset)] = value
end
|
#deep_map(ary, &block) ⇒ Object
942
943
944
945
946
947
948
949
950
951
952
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 942
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
|
#each ⇒ Object
926
927
928
929
930
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 926
def each
@data.each do |data|
yield(data)
end
end
|
#have_member ⇒ Object
887
888
889
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 887
def have_member
!@data.empty?
end
|
#include?(var) ⇒ Boolean
954
955
956
957
958
959
960
961
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 954
def include?(var)
traverse_data(@data) do |v, *rank|
if v.is_a?(SOAPBasetype) && v.data == var
return true
end
end
false
end
|
#position ⇒ Object
994
995
996
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 994
def position
@position
end
|
#replace ⇒ Object
936
937
938
939
940
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 936
def replace
@data = deep_map(@data) do |ele|
yield(ele)
end
end
|
#soap2array(ary) ⇒ Object
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 973
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
|
#to_a ⇒ Object
932
933
934
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 932
def to_a
@data.dup
end
|
#traverse ⇒ Object
963
964
965
966
967
968
969
970
971
|
# File 'lib/soap4r_19_patch/soap/baseData.rb', line 963
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
|