Class: GoApiClient::Parsers::Author

Inherits:
Object
  • Object
show all
Defined in:
lib/go_api_client/parsers/author_parser.rb

Class Method Summary collapse

Class Method Details

.parse(root) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/go_api_client/parsers/author_parser.rb', line 5

def parse(root)
  name = root.xpath('xmlns:name').first.content
  email = root.xpath('xmlns:email').first.content rescue nil
  uri = root.xpath('xmlns:uri').first.content rescue nil
  if email.nil? || email.empty?
    if name =~ /(.*) <(.+?)>/
      name, email = $1, $2
    end
  end
  GoApiClient::Domain::Author.new(
      {
          :name => name,
          :email => email,
          :uri => uri
      })
end