Class: Lotus::Atom::Author
- Inherits:
-
Atom::Person
- Object
- Atom::Person
- Lotus::Atom::Author
- Includes:
- Atom::SimpleExtensions
- Defined in:
- lib/lotus/atom/author.rb
Overview
Holds information about the author of the Feed.
Constant Summary collapse
- POCO_NAMESPACE =
The XML namespace the specifies this content.
'http://portablecontacts.net/spec/1.0'
- ACTIVITY_NAMESPACE =
The XML namespace that identifies the conforming specification.
'http://activitystrea.ms/spec/1.0/'
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#activity ⇒ Object
Gives an instance of an Lotus::Activity that parses the fields having an activity prefix.
-
#initialize(*args) ⇒ Author
constructor
A new instance of Author.
- #to_canonical ⇒ Object
- #to_xml(*args) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Author
Returns a new instance of Author.
85 86 87 88 |
# File 'lib/lotus/atom/author.rb', line 85 def initialize *args self.activity_object_type = "http://activitystrea.ms/schema/1.0/person" super(*args) end |
Instance Attribute Details
#name ⇒ Object
51 52 53 |
# File 'lib/lotus/atom/author.rb', line 51 def name @name or self[::Atom::NAMESPACE, 'name'].first end |
#poco_name ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lotus/atom/author.rb', line 55 def poco_name return @poco_name if @poco_name name = self[POCO_NAMESPACE, 'name'].first if name name = "<name>#{name}</name>" reader = XML::Reader.string(name) reader.read reader.read Lotus::Atom::Name.new(reader) else nil end end |
Class Method Details
.from_canonical(obj) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/lotus/atom/author.rb', line 96 def self.from_canonical(obj) hash = obj.to_hash hash.keys.each do |k| to_k = k if k == :display_name to_k = :displayName elsif k == :preferred_username to_k = :preferredUsername end if k == :extended_name if hash[:extended_name] hash[:"poco_name"] = Lotus::Atom::Name.new(hash[:extended_name]) end hash.delete :extended_name elsif k == :organization if hash[:organization] hash[:"poco_organization"] = Lotus::Atom::Organization.new(hash[:organization]) end hash.delete :organization elsif k == :address if hash[:address] hash[:"poco_address"] = Lotus::Atom::Address.new(hash[:address]) end hash.delete :address elsif k == :account if hash[:account] hash[:"poco_account"] = Lotus::Atom::Account.new(hash[:account]) end hash.delete :account elsif (k != :uri) && (k != :name) && (k != :email) hash[:"poco_#{to_k}"] = hash[k] hash.delete k end end self.new(hash) end |
Instance Method Details
#activity ⇒ Object
Gives an instance of an Lotus::Activity that parses the fields having an activity prefix.
92 93 94 |
# File 'lib/lotus/atom/author.rb', line 92 def activity Lotus::Activity.new(self) end |
#to_canonical ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/lotus/atom/author.rb', line 135 def to_canonical organization = self.poco_organization organization = organization.to_canonical if organization address = self.poco_address address = address.to_canonical if address account = self.poco_account account = account.to_canonical if account ext_name = self.poco_name ext_name = ext_name.to_canonical if ext_name Lotus::Author.new(:id => self.poco_id, :extended_name => ext_name, :organization => organization, :address => address, :account => account, :gender => self.poco_gender, :note => self.poco_note, :nickname => self.poco_nickname, :display_name => self.poco_displayName, :preferred_username => self.poco_preferredUsername, :updated => self.poco_updated, :published => self.poco_published, :birthday => self.poco_birthday, :anniversary => self.poco_anniversary, :uri => self.uri, :email => self.email, :name => self.name) end |
#to_xml(*args) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/lotus/atom/author.rb', line 69 def to_xml(*args) x = super(*args) if self.name node = XML::Node.new('name') node << self.name x << node end if self.poco_name x << self.poco_name.to_xml(true, root_name = 'poco:name') end x end |