class GoApiClient::Parsers::Author

Public Class Methods

parse(root) click to toggle source
# 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