Class: VORuby::VOEvent::V1_1::What

Inherits:
Described show all
Defined in:
lib/voruby/voevent/1.1/voevent.rb

Overview

Event characterization.

Instance Attribute Summary collapse

Attributes inherited from Described

#descriptions, #references

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Described

described_from_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(groups, params = nil, descriptions = nil, references = nil) ⇒ What

Returns a new instance of What.



675
676
677
678
679
# File 'lib/voruby/voevent/1.1/voevent.rb', line 675

def initialize(groups, params=nil, descriptions=nil, references=nil)
  super(descriptions, references)
  self.groups = groups
  self.params = params
end

Instance Attribute Details

#groupsObject

Returns the value of attribute groups.



673
674
675
# File 'lib/voruby/voevent/1.1/voevent.rb', line 673

def groups
  @groups
end

#paramsObject

Returns the value of attribute params.



673
674
675
# File 'lib/voruby/voevent/1.1/voevent.rb', line 673

def params
  @params
end

Class Method Details

.from_xml(xml) ⇒ Object



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
# File 'lib/voruby/voevent/1.1/voevent.rb', line 715

def self.from_xml(xml)
  root = element_from(xml)
  
  groups = REXML::XPath.match(root, 'x:Group', {'x' => obj_ns.uri})
  groups = nil if groups.size == 0
  
  params = REXML::XPath.match(root, 'x:Param', {'x' => obj_ns.uri})
  params = nil if params.size == 0
  
  self.new(
    groups ? GroupList.new(groups.collect{ |g| Group.from_xml(g) }) : nil,
    params ? ParamList.new(params.collect{ |p| Param.from_xml(p) }) : nil,
    *Described.described_from_xml(root)
  )
end

Instance Method Details

#==(w) ⇒ Object



699
700
701
702
703
# File 'lib/voruby/voevent/1.1/voevent.rb', line 699

def ==(w)
  super(w) and
  self.groups == w.groups and
  self.params == w.params
end

#to_xml(name = nil) ⇒ Object



705
706
707
708
709
710
711
712
713
# File 'lib/voruby/voevent/1.1/voevent.rb', line 705

def to_xml(name=nil)
  el = super(name)
  
  self.groups.each{ |g| el.add_element(g.to_xml('Group')) } if self.groups
  self.params.each{ |p| el.add_element(p.to_xml('Param')) } if self.params
  
  collapse_namespaces(el)
  el
end