In Files

  • soap/baseData.rb

Class/Module Index [+]

Quicksearch

SOAP::SOAPElement

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

Attributes

data[RW]

Text interface.

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) click to toggle source
 
               # File soap/baseData.rb, line 610
def self.decode(elename)
  o = SOAPElement.new(elename)
  o
end
            
from_obj(obj, namespace = nil) click to toggle 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) click to toggle 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) click to toggle 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) click to toggle source
 
               # File soap/baseData.rb, line 554
def [](idx)
  if @array.include?(idx)
    @data[@array.index(idx)]
  else
    nil
  end
end
            
[]=(idx, data) click to toggle 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) click to toggle source

Element interfaces.

 
               # File soap/baseData.rb, line 550
def add(value)
  add_member(value.elename.name, value)
end
            
each() click to toggle 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() click to toggle source
 
               # File soap/baseData.rb, line 541
def inspect
  sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename)
end
            
key?(name) click to toggle source
 
               # File soap/baseData.rb, line 571
def key?(name)
  @array.include?(name)
end
            
members() click to toggle source
 
               # File soap/baseData.rb, line 575
def members
  @array
end
            
to_obj() click to toggle 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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus