Class: SOAP::SOAPElement

Class | SOAP::SOAPElement
In: | soap/baseData.rb
Parent: | Object

SOAPElement is not typed so it is not derived from NSDBase.

### Methods

[] []= add decode each from_obj inspect key? members new to_elename to_obj

### Included Modules

Enumerable

### External Aliases

text | -> | data

### Attributes

elename | [RW] |
encodingstyle | [RW] |
extraattr | [RW] |
id | [RW] |
parent | [RW] |
position | [RW] |
precedents | [R] |
qualified | [RW] |
root | [RW] |
text | [RW] | Text interface.

### Public Class methods

decode(elename)

[Source]

    # File soap/baseData.rb, line 610
      def self.decode(elename)
        o = SOAPElement.new(elename)
        o
      end

from_obj(obj, namespace = nil)

[Source]

    # File soap/baseData.rb, line 615
      def self.from_obj(obj, namespace = nil)
        o = SOAPElement.new(nil)
        case obj
        when nil
          o.text = nil
        when Hash
          obj.each do |elename, value|
            if value.is_a?(Array)
              value.each do |subvalue|
                child = from_obj(subvalue, namespace)
                child.elename = to_elename(elename, namespace)
                o.add(child)
              end
            else
              child = from_obj(value, namespace)
              child.elename = to_elename(elename, namespace)
              o.add(child)
            end
          end
        else
          o.text = obj.to_s
        end
        o
      end

new(elename, text = nil)

[Source]

    # File soap/baseData.rb, line 521
      def initialize(elename, text = nil)
        if !elename.is_a?(XSD::QName)
          elename = XSD::QName.new(nil, elename)
        end
        @encodingstyle = LiteralNamespace
        @elename = elename
        @id = nil
        @precedents = []
        @root = false
        @parent = nil
        @position = nil
        @extraattr = {}

        @qualified = nil

        @array = []
        @data = []
        @text = text
      end

to_elename(obj, namespace = nil)

[Source]

    # File soap/baseData.rb, line 640
      def self.to_elename(obj, namespace = nil)
        if obj.is_a?(XSD::QName)
          obj
        elsif /\A(.+):([^:]+)\z/ =~ obj.to_s
          XSD::QName.new($1, $2)
        else
          XSD::QName.new(namespace, obj.to_s)
        end
      end

### Public Instance methods

[](idx)

[Source]

    # File soap/baseData.rb, line 554
      def [](idx)
        if @array.include?(idx)
          @data[@array.index(idx)]
        else
          nil
        end
      end

[]=(idx, data)

[Source]

    # File soap/baseData.rb, line 562
      def []=(idx, data)
        if @array.include?(idx)
          data.parent = self if data.respond_to?(:parent=)
          @data[@array.index(idx)] = data
        else
          add(data)
        end
      end

add(value)

Element interfaces.

[Source]

    # File soap/baseData.rb, line 550
      def add(value)
        add_member(value.elename.name, value)
      end

each() {|@array[idx], @data[idx]| ...}

[Source]

    # File soap/baseData.rb, line 602
      def each
        idx = 0
        while idx < @array.length
          yield(@array[idx], @data[idx])
          idx += 1
        end
      end

inspect()

[Source]

    # File soap/baseData.rb, line 541
      def inspect
        sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename)
      end

key?(name)

[Source]

    # File soap/baseData.rb, line 571
      def key?(name)
        @array.include?(name)
      end

members()

[Source]

    # File soap/baseData.rb, line 575
      def members
        @array
      end

to_obj()

[Source]

    # File soap/baseData.rb, line 579
      def to_obj
        if members.empty?
          @text
        else
          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
      end

[Validate]