Class: OStatus::Author

Inherits:
Atom::Person
  • Object
show all
Includes:
Atom::SimpleExtensions
Defined in:
lib/ostatus/author.rb

Overview

Holds information about the author of the Feed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Author

Returns a new instance of Author.



32
33
34
35
# File 'lib/ostatus/author.rb', line 32

def initialize *args
  self.activity_object_type = "http://activitystrea.ms/schema/1.0/person" 
  super(*args)
end

Instance Attribute Details

#nameObject



41
42
43
# File 'lib/ostatus/author.rb', line 41

def name
  @name or self[Atom::NAMESPACE, 'name'].first
end

#poco_nameObject



45
46
47
# File 'lib/ostatus/author.rb', line 45

def poco_name
  @poco_name or self[POCO_NS, 'name'].first
end

Instance Method Details

#activityObject

Gives an instance of an OStatus::Activity that parses the fields having an activity prefix.



69
70
71
# File 'lib/ostatus/author.rb', line 69

def activity
  OStatus::Activity.new(self)
end

#portable_contactsObject

Returns an instance of a PortableContacts that further describe the author’s contact information, if it exists.



75
76
77
# File 'lib/ostatus/author.rb', line 75

def portable_contacts
  PortableContacts.new(self)
end

#portable_contacts=(poco) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/ostatus/author.rb', line 79

def portable_contacts= poco
  [ 'id', 'name', 'nickname', 'updated', 'published', 'birthday',
    'anniversary', 'gender', 'note', 'connected'].each do |p|
    v = poco.send(p)
    self.send("poco_#{p}=", v) if v
  end

  self.poco_displayName = poco.display_name if poco.display_name
  self.poco_preferredUsername = poco.preferred_username if poco.preferred_username
end

#to_xml(*args) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ostatus/author.rb', line 49

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
    node = XML::Node.new('poco:name')
    node << self.poco_name
    x << node
  end

  x
end