123456789_123456789_123456789_123456789_123456789_

Class: RSS::Atom::Feed::Entry::Content

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RSS::Element
Defined in: lib/rss/atom.rb

Constant Summary

::RSS::Element - Inherited

GET_ATTRIBUTES, HAVE_CHILDREN_ELEMENTS, INDENT, MODELS, MUST_CALL_VALIDATORS, NEED_INITIALIZE_VARIABLES, PLURAL_FORMS, TO_ELEMENT_METHODS

::RSS::Atom::CommonModel - Included

ELEMENTS, NSPOOL

Class Attribute Summary

Class Method Summary

::RSS::Element - Inherited

::RSS::Utils::InheritedReader - Extended

::RSS::BaseModel - Extended

::RSS::Utils - Included

element_initialize_arguments?

This method is used inside of several different objects to determine if special behavior is needed in the constructor.

get_file_and_line_from_caller

Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined.

h,
html_escape

Takes a string s with some HTML in it, and escapes '&', '“', '<' and '>', by replacing them with the appropriate entities.

new_with_value_if_need

If value is an instance of class klass, return it, else create a new instance of klass with value value.

to_class_name

Given a name in a name_with_underscores or a name-with-dashes format, returns the CamelCase version of name.

Instance Attribute Summary

Instance Method Summary

::RSS::Element - Inherited

::RSS::SetupMaker - Included

::RSS::Utils - Included

#element_initialize_arguments?

This method is used inside of several different objects to determine if special behavior is needed in the constructor.

#get_file_and_line_from_caller

Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined.

#h,
#html_escape

Takes a string s with some HTML in it, and escapes '&', '“', '<' and '>', by replacing them with the appropriate entities.

#new_with_value_if_need

If value is an instance of class klass, return it, else create a new instance of klass with value value.

#to_class_name

Given a name in a name_with_underscores or a name-with-dashes format, returns the CamelCase version of name.

Constructor Details

This class inherits a constructor from RSS::Element

Class Method Details

.xml_getter

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 533

def xml_getter
  "xml"
end

.xml_setter

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 529

def xml_setter
  "xml="
end

Instance Attribute Details

#empty_content?Boolean (readonly, private)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 656

def empty_content?
  out_of_line? or super
end

#have_xml_content?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 549

def have_xml_content?
  inline_xhtml? or inline_other_xml?
end

#inline_html?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 595

def inline_html?
  return false if out_of_line?
  @type == "html" or mime_split == ["text", "html"]
end

#inline_other?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 604

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?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 634

def inline_other_base64?
  inline_other? and !inline_other_text? and !inline_other_xml?
end

#inline_other_text?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 611

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?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 620

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?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 591

def inline_text?
  !out_of_line? and [nil, "text", "html"].include?(@type)
end

#inline_xhtml?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 600

def inline_xhtml?
  !out_of_line? and @type == "xhtml"
end

#need_base64_encode?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 651

def need_base64_encode?
  inline_other_base64?
end

#out_of_line?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 638

def out_of_line?
  not @src.nil?
end

#xml (rw)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 553

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

#xml=(value) (rw)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 548

attr_writer :xml

Instance Method Details

#atom_validate(ignore_unknown_element, tags, uri)

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 575

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

#mime_split

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 642

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

#xhtml

[ GitHub ]

  
# File 'lib/rss/atom.rb', line 567

def xhtml
  if inline_xhtml?
    xml
  else
    nil
  end
end