Class: Lotus::Atom::Address
- Inherits:
-
Object
- Object
- Lotus::Atom::Address
- Includes:
- Atom::Xml::Parseable
- Defined in:
- lib/lotus/atom/address.rb
Overview
This class represents an OStatus PortableContacts Address object.
Constant Summary collapse
- POCO_NAMESPACE =
The XML namespace the specifies this content.
'http://portablecontacts.net/spec/1.0'
Instance Method Summary collapse
-
#initialize(o = {}) {|_self| ... } ⇒ Address
constructor
A new instance of Address.
- #to_canonical ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(o = {}) {|_self| ... } ⇒ Address
Returns a new instance of Address.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lotus/atom/address.rb', line 21 def initialize(o = {}) case o when XML::Reader o.read 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_canonical ⇒ Object
51 52 53 |
# File 'lib/lotus/atom/address.rb', line 51 def to_canonical to_hash end |
#to_hash ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lotus/atom/address.rb', line 40 def to_hash { :formatted => self.formatted, :street_address => self.streetAddress, :locality => self.locality, :region => self.region, :postal_code => self.postalCode, :country => self.country } end |