Class: Atom::Generator

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

Overview

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

The generator identifies an agent or engine used to a produce a feed.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Xml::Parseable

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

Constructor Details

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

Initialize a new Generator.

xml

An XML::Reader object.

Yields:

  • (_self)

Yield Parameters:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/atom.rb', line 88

def initialize(o = {})
  case o
  when XML::Reader
    @name = o.read_string.strip
    parse(o, :once => true)
  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 Attribute Details

#nameObject

Returns the value of attribute name.



81
82
83
# File 'lib/atom.rb', line 81

def name
  @name
end

Instance Method Details

#to_xml(nodeonly = true, name = 'generator', namespace = nil, namespace_map = Atom::Xml::NamespaceMap.new) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/atom.rb', line 104

def to_xml(nodeonly = true, name = 'generator', namespace = nil, namespace_map = Atom::Xml::NamespaceMap.new)
  node = XML::Node.new("#{namespace_map.prefix(Atom::NAMESPACE, name)}")
  node << @name if @name
  node['uri'] = @uri if @uri
  node['version'] = @version if @version
  node
end