Class: Lotus::Atom::Name

Inherits:
Object
  • Object
show all
Includes:
Atom::Xml::Parseable
Defined in:
lib/lotus/atom/name.rb

Overview

This class represents an PortableContacts Name object.

Constant Summary collapse

POCO_NAMESPACE =

The XML namespace the specifies this content.

'http://portablecontacts.net/spec/1.0'

Instance Method Summary collapse

Constructor Details

#initialize(o = {}) {|_self| ... } ⇒ Name

Returns a new instance of Name.

Yields:

  • (_self)

Yield Parameters:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lotus/atom/name.rb', line 21

def initialize(o = {})
  case o
  when XML::Reader
    parse(o, :test => true)
  when Hash
    o.each do |k, v|
      if k.to_s.include? '_'
        k = k.to_s.gsub(/_(.)/){"#{$1.upcase}"}.intern
      end
      self.send("#{k.to_s}=", v)
    end
  else
    raise ArgumentError, "Got #{o.class} but expected a Hash or XML::Reader"
  end

  yield(self) if block_given?
end

Instance Method Details

#to_canonicalObject



50
51
52
# File 'lib/lotus/atom/name.rb', line 50

def to_canonical
  to_hash
end

#to_hashObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/lotus/atom/name.rb', line 39

def to_hash
  {
    :formatted => self.formatted,
    :family_name => self.familyName,
    :given_name => self.givenName,
    :middle_name => self.middleName,
    :honorific_prefix => self.honorificPrefix,
    :honorific_suffix => self.honorificSuffix
  }
end