Class: Atom::Content::Text

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

Overview

Text content 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

- (Text) initialize(o)

Returns a new instance of Text



218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/atom.rb', line 218

def initialize(o)
  case o
  when String
    super(o)
    @type = "text"
  when XML::Reader
    super(o.read_string)
    parse(o, :once => true)
  else
    raise ArgumentError, "Got #{o} which isn't a String or XML::Reader"
  end        
end

Instance Method Details

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



231
232
233
234
235
# File 'lib/atom.rb', line 231

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 << self.to_s
  node
end