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
- .from_objs(objs) ⇒ 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.
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/soap/baseData.rb', line 564 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.
554 555 556 |
# File 'lib/soap/baseData.rb', line 554 def elename @elename end |
#encodingstyle ⇒ Object
Returns the value of attribute encodingstyle.
552 553 554 |
# File 'lib/soap/baseData.rb', line 552 def encodingstyle @encodingstyle end |
#extraattr ⇒ Object
Returns the value of attribute extraattr.
560 561 562 |
# File 'lib/soap/baseData.rb', line 560 def extraattr @extraattr end |
#id ⇒ Object
Returns the value of attribute id.
555 556 557 |
# File 'lib/soap/baseData.rb', line 555 def id @id end |
#parent ⇒ Object
Returns the value of attribute parent.
558 559 560 |
# File 'lib/soap/baseData.rb', line 558 def parent @parent end |
#position ⇒ Object
Returns the value of attribute position.
559 560 561 |
# File 'lib/soap/baseData.rb', line 559 def position @position end |
#precedents ⇒ Object (readonly)
Returns the value of attribute precedents.
556 557 558 |
# File 'lib/soap/baseData.rb', line 556 def precedents @precedents end |
#qualified ⇒ Object
Returns the value of attribute qualified.
562 563 564 |
# File 'lib/soap/baseData.rb', line 562 def qualified @qualified end |
#root ⇒ Object
Returns the value of attribute root.
557 558 559 |
# File 'lib/soap/baseData.rb', line 557 def root @root end |
#text ⇒ Object Also known as: data
Text interface.
591 592 593 |
# File 'lib/soap/baseData.rb', line 591 def text @text end |
Class Method Details
.decode(elename) ⇒ Object
655 656 657 658 |
# File 'lib/soap/baseData.rb', line 655 def self.decode(elename) o = SOAPElement.new(elename) o end |
.from_obj(obj, namespace = nil) ⇒ Object
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
# File 'lib/soap/baseData.rb', line 673 def self.from_obj(obj, namespace = nil) o = SOAPElement.new(nil) case obj when nil o.text = nil when Hash, Array 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 |
.from_objs(objs) ⇒ Object
660 661 662 663 664 665 666 667 668 669 670 671 |
# File 'lib/soap/baseData.rb', line 660 def self.from_objs(objs) objs.collect { |value| if value.is_a?(SOAPElement) value else k, v = value ele = from_obj(v) ele.elename = XSD::QName.new(nil, k) ele end } end |
Instance Method Details
#[](idx) ⇒ Object
599 600 601 602 603 604 605 |
# File 'lib/soap/baseData.rb', line 599 def [](idx) if @array.include?(idx) @data[@array.index(idx)] else nil end end |
#[]=(idx, data) ⇒ Object
607 608 609 610 611 612 613 614 |
# File 'lib/soap/baseData.rb', line 607 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.
595 596 597 |
# File 'lib/soap/baseData.rb', line 595 def add(value) add_member(value.elename.name, value) end |
#each ⇒ Object
647 648 649 650 651 652 653 |
# File 'lib/soap/baseData.rb', line 647 def each idx = 0 while idx < @array.length yield(@array[idx], @data[idx]) idx += 1 end end |
#inspect ⇒ Object
584 585 586 587 588 |
# File 'lib/soap/baseData.rb', line 584 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename) + (@text ? " #{@text.inspect}" : '') + @data.collect { |ele| "\n#{ele.inspect}" }.join.gsub(/^/, ' ') end |
#key?(name) ⇒ Boolean
616 617 618 |
# File 'lib/soap/baseData.rb', line 616 def key?(name) @array.include?(name) end |
#members ⇒ Object
620 621 622 |
# File 'lib/soap/baseData.rb', line 620 def members @array end |
#to_obj ⇒ Object
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
# File 'lib/soap/baseData.rb', line 624 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 |