Class: VORuby::VOEvent::V1_1::Author

Inherits:
Base
  • Object
show all
Defined in:
lib/voruby/voevent/1.1/voevent.rb

Defined Under Namespace

Classes: StringList

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ Author

Returns a new instance of Author.



740
741
742
# File 'lib/voruby/voevent/1.1/voevent.rb', line 740

def initialize(options={})
  options.each{ |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#contact_emailsObject

Returns the value of attribute contact_emails.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def contact_emails
  @contact_emails
end

#contact_namesObject

Returns the value of attribute contact_names.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def contact_names
  @contact_names
end

#contact_phonesObject

Returns the value of attribute contact_phones.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def contact_phones
  @contact_phones
end

#contributorsObject

Returns the value of attribute contributors.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def contributors
  @contributors
end

#logo_urlsObject

Returns the value of attribute logo_urls.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def logo_urls
  @logo_urls
end

#short_namesObject

Returns the value of attribute short_names.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def short_names
  @short_names
end

#titlesObject

Returns the value of attribute titles.



737
738
739
# File 'lib/voruby/voevent/1.1/voevent.rb', line 737

def titles
  @titles
end

Class Method Details

.from_xml(xml) ⇒ Object



865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'lib/voruby/voevent/1.1/voevent.rb', line 865

def self.from_xml(xml)
  root = element_from(xml)
  
  titles = REXML::XPath.match(root, 'x:title', {'x' => obj_ns.uri})
  titles = nil if titles.size == 0
  
  short_names = REXML::XPath.match(root, 'x:shortName', {'x' => obj_ns.uri})
  short_names = nil if short_names.size == 0
  
  logo_urls = REXML::XPath.match(root, 'x:logoURL', {'x' => obj_ns.uri})
  logo_urls = nil if logo_urls.size == 0
  
  contact_names = REXML::XPath.match(root, 'x:contactName', {'x' => obj_ns.uri})
  contact_names = nil if contact_names.size == 0
  
  contact_emails = REXML::XPath.match(root, 'x:contactEmail', {'x' => obj_ns.uri})
  contact_emails = nil if contact_emails.size == 0
  
  contact_phones = REXML::XPath.match(root, 'x:contactPhone', {'x' => obj_ns.uri})
  contact_phones = nil if contact_phones.size == 0
  
  contributors = REXML::XPath.match(root, 'x:contributor', {'x' => obj_ns.uri})
  contributors = nil if contributors.size == 0
  
  self.new(
    :titles => titles ? StringList.new(titles.collect{ |t| t.text }) : nil,
    :short_names => short_names ? StringList.new(short_names.collect{ |n| n.text }) : nil,
    :logo_urls => logo_urls ? StringList.new(logo_urls.collect{ |u| u.text }) : nil,
    :contact_names => contact_names ? StringList.new(contact_names.collect{ |n| n.text }) : nil,
    :contact_emails => contact_emails ? StringList.new(contact_emails.collect{ |e| e.text }) : nil,
    :contact_phones => contact_phones ? StringList.new(contact_phones.collect{ |p| p.text }) : nil,
    :contributors => contributors ? StringList.new(contributors.collect{ |c| c.text }) : nil
  )
end

Instance Method Details

#==(a) ⇒ Object



807
808
809
810
811
812
813
814
815
# File 'lib/voruby/voevent/1.1/voevent.rb', line 807

def ==(a)
  self.titles == a.titles and
  self.short_names == a.short_names and
  self.logo_urls == a.logo_urls and
  self.contact_names == a.contact_names and
  self.contact_emails == a.contact_emails and
  self.contact_phones == a.contact_phones and
  self.contributors == a.contributors
end

#to_xml(name = nil) ⇒ Object



817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
# File 'lib/voruby/voevent/1.1/voevent.rb', line 817

def to_xml(name=nil)
  el = element(name)
  
  self.titles.each { |t|
    e = REXML::Element.new("#{obj_ns.prefix}:title")
    e.text = t
    el.add_element(e)
  } if self.titles
  
  self.short_names.each{ |n|
    e = REXML::Element.new("#{obj_ns.prefix}:shortName")
    e.text = n
    el.add_element(e)
  } if self.short_names
  
  self.logo_urls.each{ |u|
    e = REXML::Element.new("#{obj_ns.prefix}:logoURL")
    e.text = u
    el.add_element(e)
  } if self.logo_urls
  
  self.contact_names.each{ |n|
    e = REXML::Element.new("#{obj_ns.prefix}:contactName")
    e.text = n
    el.add_element(e)
  } if self.contact_names
  
  self.contact_emails.each{ |m|
    e = REXML::Element.new("#{obj_ns.prefix}:contactEmail")
    e.text = m
    el.add_element(e)
  } if self.contact_emails
  
  self.contact_phones.each{ |p|
    e = REXML::Element.new("#{obj_ns.prefix}:contactPhone")
    e.text = p
    el.add_element(e)
  } if self.contact_phones
  
  self.contributors.each{ |c|
    e = REXML::Element.new("#{obj_ns.prefix}:contributor")
    e.text = c
    el.add_element(e)
  } if self.contributors
  
  el
end