Class: Atom::Source

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

Overview

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

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Source.

Yields:

  • (_self)

Yield Parameters:

  • _self (Atom::Source)

    the object that the method was called on



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/atom.rb', line 312

def initialize(o = nil)
  @authors, @contributors, @links = [], [], Links.new

  case o
  when XML::Reader
    unless current_node_is?(o, 'source', NAMESPACE)
      raise ArgumentError, "Invalid node for atom:source - #{o.name}(#{o.namespace})"
    end

    o.read
    parse(o)
  when Hash
    o.each do |k, v|
      self.send("#{k.to_s}=", v)
    end
  end
  
  yield(self) if block_given?   
end