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.



35
36
37
38
# File 'lib/ostatus/author.rb', line 35

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

Instance Attribute Details

#nameObject



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

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

#poco_nameObject



48
49
50
# File 'lib/ostatus/author.rb', line 48

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.



72
73
74
# File 'lib/ostatus/author.rb', line 72

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.



78
79
80
# File 'lib/ostatus/author.rb', line 78

def portable_contacts
  PortableContacts.new(self)
end

#portable_contacts=(poco) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/ostatus/author.rb', line 82

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



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

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