Class: Atom::Content::External

Inherits:
Base show all
Defined in:
lib/atom.rb

Overview

External content reference within an Atom document.

Instance Method Summary collapse

Methods inherited from Base

#==

Methods included from Xml::Parseable

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

Methods inherited from String

#constantize, #demodulize, #singularize

Constructor Details

#initialize(o) ⇒ External

this one only works with XML::Reader instances, no strings, since the content won't be inline.

Raises:

  • (ArgumentError)

219
220
221
222
223
# File 'lib/atom.rb', line 219

def initialize(o)
  raise ArgumentError, "Got #{o} which isn't an XML::Reader" unless o.kind_of?(XML::Reader)
  super("")
  parse(o, :once => true)
end

Instance Method Details

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


225
226
227
228
229
230
# File 'lib/atom.rb', line 225

def to_xml(nodeonly = true, name = 'content', namespace = nil, namespace_map = Atom::Xml::NamespaceMap.new)
  node = XML::Node.new("#{namespace_map.prefix(Atom::NAMESPACE, name)}")
  node['type'] = self.type if self.type
  node['src'] = self.src if self.src
  node
end