Class: OStatus::PortableContacts
- Inherits:
-
Object
- Object
- OStatus::PortableContacts
- Defined in:
- lib/ostatus/portable_contacts.rb
Overview
Holds information about the extended contact information in the Feed given in the Portable Contacts specification.
Instance Method Summary collapse
-
#anniversary ⇒ Object
Returns the anniversary of the contact, if it exists.
-
#birthday ⇒ Object
Returns the birthday of the contact, if it exists.
-
#connected ⇒ Object
Returns a boolean that indicates that a bi-directional connection has been established between the user and the contact, if it is able to assert this.
-
#display_name ⇒ Object
Returns the display_name of the contact, if it exists.
-
#gender ⇒ Object
Returns the gender of the contact, if it exists.
-
#id ⇒ Object
Returns the id of the contact, if it exists.
-
#initialize(author_node) ⇒ PortableContacts
constructor
Instantiates a OStatus::PortableContacts object from either a given root that contains all <poco:*> tags as a Nokogiri::XML::Element or a Hash containing the properties.
-
#name ⇒ Object
Returns the name of the contact, if it exists.
-
#nickname ⇒ Object
Returns the nickname of the contact, if it exists.
-
#note ⇒ Object
Returns the note of the contact, if it exists.
-
#preferred_username ⇒ Object
Returns the preferred username of the contact, if it exists.
-
#published ⇒ Object
Returns the published of the contact, if it exists.
-
#updated ⇒ Object
Returns the updated of the contact, if it exists.
Constructor Details
#initialize(author_node) ⇒ PortableContacts
Instantiates a OStatus::PortableContacts object from either a given root that contains all <poco:*> tags as a Nokogiri::XML::Element or a Hash containing the properties.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ostatus/portable_contacts.rb', line 10 def initialize() if .class == Hash @poco_data = @poco = nil else @poco = @poco_data = nil end end |
Instance Method Details
#anniversary ⇒ Object
Returns the anniversary of the contact, if it exists.
81 82 83 84 85 86 87 |
# File 'lib/ostatus/portable_contacts.rb', line 81 def anniversary return @poco_data[:anniversary] unless @poco_data == nil anni = pick_first_node(@poco.xpath('./poco:anniversary')) if anni != nil Date.parse(anni) end end |
#birthday ⇒ Object
Returns the birthday of the contact, if it exists.
72 73 74 75 76 77 78 |
# File 'lib/ostatus/portable_contacts.rb', line 72 def birthday return @poco_data[:birthday] unless @poco_data == nil bday = pick_first_node(@poco.xpath('./poco:birthday')) if bday != nil Date.parse(bday) end end |
#connected ⇒ Object
Returns a boolean that indicates that a bi-directional connection has been established between the user and the contact, if it is able to assert this.
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ostatus/portable_contacts.rb', line 110 def connected return @poco_data[:connected] unless @poco_data == nil str = pick_first_node(@poco.xpath('./poco:connected')) return nil if str == nil if str == "true" true elsif str == "false" false else nil end end |
#display_name ⇒ Object
Returns the display_name of the contact, if it exists.
36 37 38 39 |
# File 'lib/ostatus/portable_contacts.rb', line 36 def display_name return @poco_data[:display_name] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:displayName')) end |
#gender ⇒ Object
Returns the gender of the contact, if it exists.
90 91 92 93 |
# File 'lib/ostatus/portable_contacts.rb', line 90 def gender return @poco_data[:gender] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:gender')) end |
#id ⇒ Object
Returns the id of the contact, if it exists.
30 31 32 33 |
# File 'lib/ostatus/portable_contacts.rb', line 30 def id return @poco_data[:id] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:id')) end |
#name ⇒ Object
Returns the name of the contact, if it exists.
42 43 44 45 |
# File 'lib/ostatus/portable_contacts.rb', line 42 def name return @poco_data[:name] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:name')) end |
#nickname ⇒ Object
Returns the nickname of the contact, if it exists.
48 49 50 51 |
# File 'lib/ostatus/portable_contacts.rb', line 48 def nickname return @poco_data[:nickname] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:nickname')) end |
#note ⇒ Object
Returns the note of the contact, if it exists.
96 97 98 99 |
# File 'lib/ostatus/portable_contacts.rb', line 96 def note return @poco_data[:note] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:note')) end |
#preferred_username ⇒ Object
Returns the preferred username of the contact, if it exists.
102 103 104 105 |
# File 'lib/ostatus/portable_contacts.rb', line 102 def preferred_username return @poco_data[:preferred_username] unless @poco_data == nil pick_first_node(@poco.xpath('./poco:preferredUsername')) end |
#published ⇒ Object
Returns the published of the contact, if it exists.
54 55 56 57 58 59 60 |
# File 'lib/ostatus/portable_contacts.rb', line 54 def published return @poco_data[:published] unless @poco_data == nil pub = pick_first_node(@poco.xpath('./poco:published')) if pub != nil DateTime.parse(pub) end end |
#updated ⇒ Object
Returns the updated of the contact, if it exists.
63 64 65 66 67 68 69 |
# File 'lib/ostatus/portable_contacts.rb', line 63 def updated return @poco_data[:updated] unless @poco_data == nil upd = pick_first_node(@poco.xpath('./poco:updated')) if upd != nil DateTime.parse(upd) end end |