Class: SOAP::SOAPElement
- Includes:
- Enumerable
- Defined in:
- lib/soap/baseData.rb
Overview
SOAPElement is not typed so it is not derived from NSDBase.
Instance Attribute Summary collapse
-
#elename ⇒ Object
Returns the value of attribute elename.
-
#encodingstyle ⇒ Object
Returns the value of attribute encodingstyle.
-
#extraattr ⇒ Object
Returns the value of attribute extraattr.
-
#id ⇒ Object
Returns the value of attribute id.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#position ⇒ Object
Returns the value of attribute position.
-
#precedents ⇒ Object
readonly
Returns the value of attribute precedents.
-
#qualified ⇒ Object
Returns the value of attribute qualified.
-
#root ⇒ Object
Returns the value of attribute root.
-
#text ⇒ Object
(also: #data)
Text interface.
Class Method Summary collapse
- .decode(elename) ⇒ Object
- .from_obj(obj, namespace = nil) ⇒ Object
- .to_elename(obj, namespace = nil) ⇒ Object
Instance Method Summary collapse
- #[](idx) ⇒ Object
- #[]=(idx, data) ⇒ Object
-
#add(value) ⇒ Object
Element interfaces.
- #each ⇒ Object
-
#initialize(elename, text = nil) ⇒ SOAPElement
constructor
A new instance of SOAPElement.
- #inspect ⇒ Object
- #key?(name) ⇒ Boolean
- #members ⇒ Object
- #to_obj ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(elename, text = nil) ⇒ SOAPElement
Returns a new instance of SOAPElement.
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/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 |
Instance Attribute Details
#elename ⇒ Object
Returns the value of attribute elename
511 512 513 |
# File 'lib/soap/baseData.rb', line 511 def elename @elename end |
#encodingstyle ⇒ Object
Returns the value of attribute encodingstyle
509 510 511 |
# File 'lib/soap/baseData.rb', line 509 def encodingstyle @encodingstyle end |
#extraattr ⇒ Object
Returns the value of attribute extraattr
517 518 519 |
# File 'lib/soap/baseData.rb', line 517 def extraattr @extraattr end |
#id ⇒ Object
Returns the value of attribute id
512 513 514 |
# File 'lib/soap/baseData.rb', line 512 def id @id end |
#parent ⇒ Object
Returns the value of attribute parent
515 516 517 |
# File 'lib/soap/baseData.rb', line 515 def parent @parent end |
#position ⇒ Object
Returns the value of attribute position
516 517 518 |
# File 'lib/soap/baseData.rb', line 516 def position @position end |
#precedents ⇒ Object (readonly)
Returns the value of attribute precedents
513 514 515 |
# File 'lib/soap/baseData.rb', line 513 def precedents @precedents end |
#qualified ⇒ Object
Returns the value of attribute qualified
519 520 521 |
# File 'lib/soap/baseData.rb', line 519 def qualified @qualified end |
#root ⇒ Object
Returns the value of attribute root
514 515 516 |
# File 'lib/soap/baseData.rb', line 514 def root @root end |
#text ⇒ Object Also known as: data
Text interface.
546 547 548 |
# File 'lib/soap/baseData.rb', line 546 def text @text end |
Class Method Details
.decode(elename) ⇒ Object
610 611 612 613 |
# File 'lib/soap/baseData.rb', line 610 def self.decode(elename) o = SOAPElement.new(elename) o end |
.from_obj(obj, namespace = nil) ⇒ Object
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/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 |
.to_elename(obj, namespace = nil) ⇒ Object
640 641 642 643 644 645 646 647 648 |
# File 'lib/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 |
Instance Method Details
#[](idx) ⇒ Object
554 555 556 557 558 559 560 |
# File 'lib/soap/baseData.rb', line 554 def [](idx) if @array.include?(idx) @data[@array.index(idx)] else nil end end |
#[]=(idx, data) ⇒ Object
562 563 564 565 566 567 568 569 |
# File 'lib/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) ⇒ Object
Element interfaces.
550 551 552 |
# File 'lib/soap/baseData.rb', line 550 def add(value) add_member(value.elename.name, value) end |
#each ⇒ Object
602 603 604 605 606 607 608 |
# File 'lib/soap/baseData.rb', line 602 def each idx = 0 while idx < @array.length yield(@array[idx], @data[idx]) idx += 1 end end |
#inspect ⇒ Object
541 542 543 |
# File 'lib/soap/baseData.rb', line 541 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename) end |
#key?(name) ⇒ Boolean
571 572 573 |
# File 'lib/soap/baseData.rb', line 571 def key?(name) @array.include?(name) end |
#members ⇒ Object
575 576 577 |
# File 'lib/soap/baseData.rb', line 575 def members @array end |
#to_obj ⇒ Object
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/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 |