Class: Atom::Content::Text
Overview
Text content within an Atom document.
Instance Method Summary collapse
-
#initialize(o) ⇒ Text
constructor
A new instance of Text.
- #to_xml(nodeonly = true, name = 'content', namespace = nil, namespace_map = Atom::Xml::NamespaceMap.new) ⇒ Object
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) ⇒ Text
Returns a new instance of Text.
242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/atom.rb', line 242 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
255 256 257 258 259 |
# File 'lib/atom.rb', line 255 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 |