Class: Atom::Person

Inherits:
Object
  • Object
show all
Includes:
Xml::Parseable
Defined in:
lib/atom.rb

Overview

Represents a Person as defined by the Atom Syndication Format specification.

A Person is used for all author and contributor attributes.

See also www.atomenabled.org/developers/syndication/atom-format-spec.php#atomPersonConstruct

Instance Method Summary collapse

Methods included from Xml::Parseable

#==, #accessor_name, #current_node_is?, included, #next_node_is?, #parse, #to_xml

Constructor Details

#initialize(o = {}) {|_self| ... } ⇒ Person

Initialize a new person.

o

An XML::Reader object or a hash. Valid hash keys are :name, :uri and :email.

Yields:

  • (_self)

Yield Parameters:

  • _self (Atom::Person)

    the object that the method was called on



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/atom.rb', line 150

def initialize(o = {})
  case o
  when XML::Reader
    o.read
    parse(o)
  when Hash
    o.each do |k, v|
      self.send("#{k.to_s}=", v)
    end
  else
    raise ArgumentError, "Got #{o.class} but expected a Hash or XML::Reader"
  end
  
  yield(self) if block_given?
end

Instance Method Details

#inspectObject



166
167
168
# File 'lib/atom.rb', line 166

def inspect
  "<Atom::Person name:'#{name}' uri:'#{uri}' email:'#{email}"
end