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

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

Methods inherited from String

#constantize, #demodulize, #singularize

Constructor Details

#initialize(o) ⇒ Text

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

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



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