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

#initialize(o) ⇒ Text

Returns a new instance of Text.



241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/atom.rb', line 241

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

Instance Method Details

#to_xml(builder = nil, name = 'content', namespace = nil, namespace_handler = nil) ⇒ Object



254
255
256
257
258
# File 'lib/atom.rb', line 254

def to_xml(builder = nil, name = 'content', namespace = nil, namespace_handler = nil)
  namespace_handler.prefix(builder, Atom::NAMESPACE) if namespace_handler
  builder.send("#{name}_", self.to_s)
  builder.doc.root
end