Class: GoApiClient::Atom::Author

Inherits:
Object
  • Object
show all
Includes:
Helpers::SimpleAttributesSupport
Defined in:
lib/go_api_client/atom/author.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, attributes = {}) ⇒ Author

Returns a new instance of Author.



9
10
11
12
# File 'lib/go_api_client/atom/author.rb', line 9

def initialize(root, attributes={})
  @root = root
  super(attributes)
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



5
6
7
# File 'lib/go_api_client/atom/author.rb', line 5

def email
  @email
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/go_api_client/atom/author.rb', line 5

def name
  @name
end

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/go_api_client/atom/author.rb', line 5

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
33
34
# File 'lib/go_api_client/atom/author.rb', line 29

def ==(other)
  other && self.class.equal?(other.class) &&
  name == other.name &&
  email == other.email &&
  uri == other.uri
end

#hashObject



36
37
38
# File 'lib/go_api_client/atom/author.rb', line 36

def hash
  self.class.hash ^ name.hash ^ email.hash ^ uri.hash
end

#parse!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/go_api_client/atom/author.rb', line 14

def parse!
  self.name     = @root.xpath('xmlns:name').first.content
  self.email    = @root.xpath('xmlns:email').first.content rescue nil
  self.uri      = @root.xpath('xmlns:uri').first.content   rescue nil

  if email.nil? || email.empty?
    if name =~ /(.*) <(.+?)>/
      self.name, self.email = $1, $2
    end
  end

  @root = nil
  self
end