Parent

Included Modules

Files

Class Index [+]

Quicksearch

SOAP::SOAPArray

Constants

ITEM_NAME
TypeParseRegexp

Attributes

sparse[RW]
offset[R]
rank[R]
size[RW]
size_fixed[RW]
arytype[R]

Public Class Methods

new(type = nil, rank = 1, arytype = nil) click to toggle source
     # File lib/soap/baseData.rb, line 865
865:   def initialize(type = nil, rank = 1, arytype = nil)
866:     super()
867:     @type = type || ValueArrayName
868:     @rank = rank
869:     @data = Array.new
870:     @sparse = false
871:     @offset = Array.new(rank, 0)
872:     @size = Array.new(rank, 0)
873:     @size_fixed = false
874:     @position = nil
875:     @arytype = arytype
876:   end

Private Class Methods

create_arytype(typename, rank) click to toggle source
      # File lib/soap/baseData.rb, line 1076
1076:   def self.create_arytype(typename, rank)
1077:     "#{typename}[" << ',' * (rank - 1) << ']'
1078:   end
decode(elename, type, arytype) click to toggle source
      # File lib/soap/baseData.rb, line 1054
1054:   def self.decode(elename, type, arytype)
1055:     typestr, nofary = parse_type(arytype.name)
1056:     rank = nofary.count(',') + 1
1057:     plain_arytype = XSD::QName.new(arytype.namespace, typestr)
1058:     o = SOAPArray.new(type, rank, plain_arytype)
1059:     size = []
1060:     nofary.split(',').each do |s|
1061:       if s.empty?
1062:         size.clear
1063:         break
1064:       else
1065:         size << s.to_i
1066:       end
1067:     end
1068:     unless size.empty?
1069:       o.size = size
1070:       o.size_fixed = true
1071:     end
1072:     o.elename = elename
1073:     o
1074:   end
parse_type(string) click to toggle source
      # File lib/soap/baseData.rb, line 1082
1082:   def self.parse_type(string)
1083:     TypeParseRegexp =~ string
1084:     return $1, $2
1085:   end

Public Instance Methods

[](*idxary) click to toggle source
     # File lib/soap/baseData.rb, line 891
891:   def [](*idxary)
892:     if idxary.size != @rank
893:       raise ArgumentError.new("given #{idxary.size} params does not match rank: #{@rank}")
894:     end
895:     retrieve(idxary)
896:   end
[]=(*idxary) click to toggle source
     # File lib/soap/baseData.rb, line 898
898:   def []=(*idxary)
899:     value = idxary.slice!(1)
900:     if idxary.size != @rank
901:       raise ArgumentError.new("given #{idxary.size} params(#{idxary}) does not match rank: #{@rank}")
902:     end
903:     idx = 0
904:     while idx < idxary.size
905:       if idxary[idx] + 1 > @size[idx]
906:         @size[idx] = idxary[idx] + 1
907:       end
908:       idx += 1
909:     end
910:     data = retrieve(idxary[0, idxary.size - 1])
911:     data[idxary.last] = value
912:     if value.is_a?(SOAPType)
913:       value.elename = ITEM_NAME
914:       # Sync type
915:       unless @type.name
916:         @type = XSD::QName.new(value.type.namespace,
917:           SOAPArray.create_arytype(value.type.name, @rank))
918:       end
919:       value.type ||= @type
920:     end
921:     @offset = idxary
922:     value.parent = self if value.respond_to?(:parent=)
923:     offsetnext
924:   end
add(value) click to toggle source
     # File lib/soap/baseData.rb, line 883
883:   def add(value)
884:     self[*(@offset)] = value
885:   end
deep_map(ary, &block) click to toggle source
     # File lib/soap/baseData.rb, line 942
942:   def deep_map(ary, &block)
943:     ary.collect do |ele|
944:       if ele.is_a?(Array)
945:         deep_map(ele, &block)
946:       else
947:         new_obj = block.call(ele)
948:         new_obj.elename = ITEM_NAME
949:         new_obj
950:       end
951:     end
952:   end
each() click to toggle source
     # File lib/soap/baseData.rb, line 926
926:   def each
927:     @data.each do |data|
928:       yield(data)
929:     end
930:   end
have_member() click to toggle source
     # File lib/soap/baseData.rb, line 887
887:   def have_member
888:     !@data.empty?
889:   end
include?(var) click to toggle source
     # File lib/soap/baseData.rb, line 954
954:   def include?(var)
955:     traverse_data(@data) do |v, *rank|
956:       if v.is_a?(SOAPBasetype) && v.data == var
957:         return true
958:       end
959:     end
960:     false
961:   end
offset=(var) click to toggle source
     # File lib/soap/baseData.rb, line 878
878:   def offset=(var)
879:     @offset = var
880:     @sparse = true
881:   end
position() click to toggle source
     # File lib/soap/baseData.rb, line 994
994:   def position
995:     @position
996:   end
replace() click to toggle source
     # File lib/soap/baseData.rb, line 936
936:   def replace
937:     @data = deep_map(@data) do |ele|
938:       yield(ele)
939:     end
940:   end
soap2array(ary) click to toggle source
     # File lib/soap/baseData.rb, line 973
973:   def soap2array(ary)
974:     traverse_data(@data) do |v, *position|
975:       iteary = ary
976:       rank = 1
977:       while rank < position.size
978:         idx = position[rank - 1]
979:         if iteary[idx].nil?
980:           iteary = iteary[idx] = Array.new
981:         else
982:           iteary = iteary[idx]
983:         end
984:         rank += 1
985:       end
986:       if block_given?
987:         iteary[position.last] = yield(v)
988:       else
989:         iteary[position.last] = v
990:       end
991:     end
992:   end
to_a() click to toggle source
     # File lib/soap/baseData.rb, line 932
932:   def to_a
933:     @data.dup
934:   end
traverse() click to toggle source
     # File lib/soap/baseData.rb, line 963
963:   def traverse
964:     traverse_data(@data) do |v, *rank|
965:       unless @sparse
966:        yield(v)
967:       else
968:        yield(v, *rank) if v && !v.is_a?(SOAPNil)
969:       end
970:     end
971:   end

Private Instance Methods

offsetnext() click to toggle source
      # File lib/soap/baseData.rb, line 1036
1036:   def offsetnext
1037:     move = false
1038:     idx = @offset.size - 1
1039:     while !move && idx >= 0
1040:       @offset[idx] += 1
1041:       if @size_fixed
1042:         if @offset[idx] < @size[idx]
1043:           move = true
1044:         else
1045:           @offset[idx] = 0
1046:           idx -= 1
1047:         end
1048:       else
1049:         move = true
1050:       end
1051:     end
1052:   end
ranksize(rank) click to toggle source
      # File lib/soap/baseData.rb, line 1032
1032:   def ranksize(rank)
1033:     @size[rank - 1]
1034:   end
retrieve(idxary) click to toggle source
      # File lib/soap/baseData.rb, line 1002
1002:   def retrieve(idxary)
1003:     data = @data
1004:     rank = 1
1005:     while rank <= idxary.size
1006:       idx = idxary[rank - 1]
1007:       if data[idx].nil?
1008:         data = data[idx] = Array.new
1009:       else
1010:         data = data[idx]
1011:       end
1012:       rank += 1
1013:     end
1014:     data
1015:   end
traverse_data(data, rank = 1) click to toggle source
      # File lib/soap/baseData.rb, line 1017
1017:   def traverse_data(data, rank = 1)
1018:     idx = 0
1019:     while idx < ranksize(rank)
1020:       if rank < @rank and data[idx]
1021:         traverse_data(data[idx], rank + 1) do |*v|
1022:           v[1, 0] = idx
1023:           yield(*v)
1024:         end
1025:       else
1026:         yield(data[idx], idx)
1027:       end
1028:       idx += 1
1029:     end
1030:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.