Class: OStatus::Author

Inherits:
Object
  • Object
show all
Defined in:
lib/ostatus/author.rb

Overview

Holds information about the author of the Feed.

Instance Method Summary collapse

Constructor Details

#initialize(author_node) ⇒ Author

Instantiates an Author object either from a given <author></author> root passed as an instance of a Nokogiri::XML::Element or a Hash containing the properties.



12
13
14
15
16
17
18
19
20
# File 'lib/ostatus/author.rb', line 12

def initialize(author_node)
  if author_node.class == Hash
    @author_data = author_node
    @author = nil
  else
    @author = author_node
    @author_data = nil
  end
end

Instance Method Details

#activityObject

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



24
25
26
# File 'lib/ostatus/author.rb', line 24

def activity
  OStatus::Activity.new(@author)
end

#emailObject

Returns the email of the author, if it exists.



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

def email
  return @author_data[:email] unless @author_data == nil
  pick_first_node(@author.css('email'))
end

#nameObject

Returns the name of the author, if it exists.



38
39
40
41
# File 'lib/ostatus/author.rb', line 38

def name
  return @author_data[:name] unless @author_data == nil
  pick_first_node(@author.css('name'))
end

#portable_contactsObject

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



57
58
59
60
# File 'lib/ostatus/author.rb', line 57

def portable_contacts
  return @author_data[:portable_contacts] unless @author_data == nil
  PortableContacts.new(@author)
end

#uriObject

Returns the uri of the author, if it exists.



50
51
52
53
# File 'lib/ostatus/author.rb', line 50

def uri
  return @author_data[:uri] unless @author_data == nil
  pick_first_node(@author.css('uri'))
end