Class: SOAP::SOAPArray

Class | SOAP::SOAPArray
In: | soap/baseData.rb
Parent: | XSD::NSDBase

### Methods

[] []= add decode deep_map each include? new offset= position replace soap2array to_a traverse

### Included Modules

SOAPCompoundtype Enumerable

### Constants

ITEM_NAME | = | XSD::QName.new(nil, 'item')
TypeParseRegexp | = | Regexp.new('^(.+)\[([\d,]*)\]$')

### Attributes

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

### Public Class methods

decode(elename, type, arytype)

Module function

[Source]

    # File soap/baseData.rb, line 903
      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

new(type = nil, rank = 1, arytype = nil)

[Source]

    # File soap/baseData.rb, line 707
      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

### Public Instance methods

[](*idxary)

[Source]

    # File soap/baseData.rb, line 729
      def [](*idxary)
        if idxary.size != @rank
          raise ArgumentError.new("given #{idxary.size} params does not match rank: #{@rank}")
        end

        retrieve(idxary)
      end

[]=(*idxary)

[Source]

    # File soap/baseData.rb, line 737
      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
          # Sync type
          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)

[Source]

    # File soap/baseData.rb, line 725
      def add(value)
        self[*(@offset)] = value
      end

deep_map(ary, &block)

[Source]

    # File soap/baseData.rb, line 787
      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() {|data| ...}

[Source]

    # File soap/baseData.rb, line 771
      def each
        @data.each do |data|
          yield(data)
        end
      end

include?(var)

[Source]

    # File soap/baseData.rb, line 799
      def include?(var)
        traverse_data(@data) do |v, *rank|
          if v.is_a?(SOAPBasetype) && v.data == var
            return true
          end
        end
        false
      end

offset=(var)

[Source]

    # File soap/baseData.rb, line 720
      def offset=(var)
        @offset = var
        @sparse = true
      end

position()

[Source]

    # File soap/baseData.rb, line 839
      def position
        @position
      end

replace() {|ele| ...}

[Source]

    # File soap/baseData.rb, line 781
      def replace
        @data = deep_map(@data) do |ele|
          yield(ele)
        end
      end

soap2array(ary) {|v| ...}

[Source]

    # File soap/baseData.rb, line 818
      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()

[Source]

    # File soap/baseData.rb, line 777
      def to_a
        @data.dup
      end

traverse() {|v| ...}

[Source]

    # File soap/baseData.rb, line 808
      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

[Validate]