class RSS::Atom::Feed::Entry::Content

Contains or links to the content of the Entry. It has the following attributes:

  • type

  • src

Reference: validator.w3.org/feed/docs/rfc4287.html#element.content

Attributes

xml[W]

Returns the element content in XML.

Public Class Methods

xml_getter() click to toggle source
# File rss-0.2.9/lib/rss/atom.rb, line 620
def xml_getter
  "xml"
end
xml_setter() click to toggle source
# File rss-0.2.9/lib/rss/atom.rb, line 616
def xml_setter
  "xml="
end

Public Instance Methods

atom_validate(ignore_unknown_element, tags, uri) click to toggle source

Raises a MissingAttributeError, NotAvailableValueError, MissingTagError or NotExpectedTagError if the element is not properly formatted.

# File rss-0.2.9/lib/rss/atom.rb, line 670
def atom_validate(ignore_unknown_element, tags, uri)
  if out_of_line?
    raise MissingAttributeError.new(tag_name, "type") if @type.nil?
    unless (content.nil? or content.empty?)
      raise NotAvailableValueError.new(tag_name, content)
    end
  elsif inline_xhtml?
    if @xml.nil?
      raise MissingTagError.new("div", tag_name)
    end
    unless @xml.name == "div" and @xml.uri == XHTML_URI
      raise NotExpectedTagError.new(@xml.name, @xml.uri, tag_name)
    end
  end
end
have_xml_content?() click to toggle source

Returns true if the element has inline XML content.

# File rss-0.2.9/lib/rss/atom.rb, line 639
def have_xml_content?
  inline_xhtml? or inline_other_xml?
end
inline_html?() click to toggle source

Returns true if the element contains inline content that has a HTML media type.

# File rss-0.2.9/lib/rss/atom.rb, line 694
def inline_html?
  return false if out_of_line?
  @type == "html" or mime_split == ["text", "html"]
end
inline_other?() click to toggle source

Returns true if the element contains inline content that has a MIME media type.

# File rss-0.2.9/lib/rss/atom.rb, line 707
def inline_other?
  return false if out_of_line?
  media_type, subtype = mime_split
  return false if media_type.nil? or subtype.nil?
  true
end
inline_other_base64?() click to toggle source

Returns true if the element contains inline content encoded in base64.

# File rss-0.2.9/lib/rss/atom.rb, line 743
def inline_other_base64?
  inline_other? and !inline_other_text? and !inline_other_xml?
end
inline_other_text?() click to toggle source

Returns true if the element contains inline content that has a text media type.

# File rss-0.2.9/lib/rss/atom.rb, line 716
def inline_other_text?
  return false unless inline_other?
  return false if inline_other_xml?

  media_type, = mime_split
  return true if "text" == media_type.downcase
  false
end
inline_other_xml?() click to toggle source

Returns true if the element contains inline content that has a XML media type.

# File rss-0.2.9/lib/rss/atom.rb, line 727
def inline_other_xml?
  return false unless inline_other?

  media_type, subtype = mime_split
  normalized_mime_type = "#{media_type}/#{subtype}".downcase
  if /(?:\+xml|^xml)$/ =~ subtype or
      %w(text/xml-external-parsed-entity
         application/xml-external-parsed-entity
         application/xml-dtd).find {|x| x == normalized_mime_type}
    return true
  end
  false
end
inline_text?() click to toggle source

Returns true if the element contains inline content that has a text or HTML media type, or no media type at all.

# File rss-0.2.9/lib/rss/atom.rb, line 688
def inline_text?
  !out_of_line? and [nil, "text", "html"].include?(@type)
end
inline_xhtml?() click to toggle source

Returns true if the element contains inline content that has a XHTML media type.

# File rss-0.2.9/lib/rss/atom.rb, line 701
def inline_xhtml?
  !out_of_line? and @type == "xhtml"
end
mime_split() click to toggle source

Splits the type attribute into an array, e.g. [“text”, “xml”]

# File rss-0.2.9/lib/rss/atom.rb, line 753
def mime_split
  media_type = subtype = nil
  if /\A\s*([a-z]+)\/([a-z\+]+)\s*(?:;.*)?\z/i =~ @type.to_s
    media_type = $1.downcase
    subtype = $2.downcase
  end
  [media_type, subtype]
end
need_base64_encode?() click to toggle source

Returns true if the content needs to be encoded in base64.

# File rss-0.2.9/lib/rss/atom.rb, line 763
def need_base64_encode?
  inline_other_base64?
end
out_of_line?() click to toggle source

Returns true if the element contains linked content.

# File rss-0.2.9/lib/rss/atom.rb, line 748
def out_of_line?
  not @src.nil?
end
xhtml() click to toggle source

Returns the element content in XHTML.

# File rss-0.2.9/lib/rss/atom.rb, line 659
def xhtml
  if inline_xhtml?
    xml
  else
    nil
  end
end
xml() click to toggle source

Returns or builds the element content in XML.

# File rss-0.2.9/lib/rss/atom.rb, line 644
def xml
  return @xml unless inline_xhtml?
  return @xml if @xml.nil?
  if @xml.is_a?(XML::Element) and
      [@xml.name, @xml.uri] == ["div", XHTML_URI]
    return @xml
  end

  children = @xml
  children = [children] unless children.is_a?(Array)
  XML::Element.new("div", nil, XHTML_URI,
                   {"xmlns" => XHTML_URI}, children)
end

Private Instance Methods

empty_content?() click to toggle source
Calls superclass method RSS::Element#empty_content?
# File rss-0.2.9/lib/rss/atom.rb, line 768
def empty_content?
  out_of_line? or super
end