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

Methods included from Xml::Parseable

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

Constructor Details

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

Returns a new instance of Source.

Yields:

  • (_self)

Yield Parameters:

  • _self (Atom::Source)

    the object that the method was called on



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/atom.rb', line 367

def initialize(o = {})
  @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
  else
    raise ArgumentError, "Got #{o.class} but expected a Hash or XML::Reader"
  end
  
  yield(self) if block_given?   
end