Class: Atom::Person

Inherits:
Element show all
Defined in:
lib/atomutil.rb

Overview

Atom::Person

This class represents person construct Use this for ‘author’ or ‘contributor’ elements. You also can use Atom::Author or Atom::Contributor directly for each element, But this class can be converted to each class’s object easily with ‘to_author’ or ‘to_contributor’ method.

Example:

person = Atom::Person.new
person.name = "John"
person.email = "[email protected]"
person.url = "http://example.com/"
entry = Atom::Entry.new
entry.add_authors person.to_author
entry.add_contributor person.to_contributor

Direct Known Subclasses

Author, Contributor

Instance Attribute Summary

Attributes inherited from Element

#elem

Instance Method Summary collapse

Methods inherited from Element

#add, element_attr_accessor, element_attr_accessors, element_datetime_accessor, element_datetime_accessors, element_name, element_ns, element_object_list_accessor, element_text_accessor, element_text_accessors, element_text_list_accessor, #get, #get_attr, #get_object, #get_objects, #getlist, #initialize, new, ns, #set, #set_attr, #to_s

Constructor Details

This class inherits a constructor from Atom::Element

Instance Method Details

#to_authorObject

Convert to an Atom::Author object



632
633
634
635
636
637
638
# File 'lib/atomutil.rb', line 632

def to_author
  author = Author.new
  author.name = self.name
  author.email = self.email unless self.email.nil?
  author.uri = self.uri unless self.uri.nil?
  author
end

#to_contributorObject

Convert to an Atom::Contributor object



640
641
642
643
644
645
646
# File 'lib/atomutil.rb', line 640

def to_contributor
  contributor = Contributor.new
  contributor.name = self.name
  contributor.email = self.email unless self.email.nil?
  contributor.uri = self.uri unless self.uri.nil?
  contributor
end