Class RSS::Atom::Feed::Entry::Content
In: lib/rss/atom.rb
Parent: RSS::Element

Methods

Included Modules

CommonModel

Attributes

xml  [W] 

Public Class methods

[Source]

     # File lib/rss/atom.rb, line 449
449:             def xml_getter
450:               "xml"
451:             end

[Source]

     # File lib/rss/atom.rb, line 445
445:             def xml_setter
446:               "xml="
447:             end

Public Instance methods

[Source]

     # File lib/rss/atom.rb, line 491
491:           def atom_validate(ignore_unknown_element, tags, uri)
492:             if out_of_line?
493:               raise MissingAttributeError.new(tag_name, "type") if @type.nil?
494:               unless (content.nil? or content.empty?)
495:                 raise NotAvailableValueError.new(tag_name, content)
496:               end
497:             elsif inline_xhtml?
498:               if @xml.nil?
499:                 raise MissingTagError.new("div", tag_name)
500:               end
501:               unless @xml.name == "div" and @xml.uri == XHTML_URI
502:                 raise NotExpectedTagError.new(@xml.name, @xml.uri, tag_name)
503:               end
504:             end
505:           end

[Source]

     # File lib/rss/atom.rb, line 465
465:           def have_xml_content?
466:             inline_xhtml? or inline_other_xml?
467:           end

[Source]

     # File lib/rss/atom.rb, line 511
511:           def inline_html?
512:             return false if out_of_line?
513:             @type == "html" or mime_split == ["text", "html"]
514:           end

[Source]

     # File lib/rss/atom.rb, line 520
520:           def inline_other?
521:             return false if out_of_line?
522:             media_type, subtype = mime_split
523:             return false if media_type.nil? or subtype.nil?
524:             true
525:           end

[Source]

     # File lib/rss/atom.rb, line 550
550:           def inline_other_base64?
551:             inline_other? and !inline_other_text? and !inline_other_xml?
552:           end

[Source]

     # File lib/rss/atom.rb, line 527
527:           def inline_other_text?
528:             return false unless inline_other?
529:             return false if inline_other_xml?
530: 
531:             media_type, subtype = mime_split
532:             return true if "text" == media_type.downcase
533:             false
534:           end

[Source]

     # File lib/rss/atom.rb, line 536
536:           def inline_other_xml?
537:             return false unless inline_other?
538: 
539:             media_type, subtype = mime_split
540:             normalized_mime_type = "#{media_type}/#{subtype}".downcase
541:             if /(?:\+xml|^xml)$/ =~ subtype or
542:                 %w(text/xml-external-parsed-entity
543:                    application/xml-external-parsed-entity
544:                    application/xml-dtd).find {|x| x == normalized_mime_type}
545:               return true
546:             end
547:             false
548:           end

[Source]

     # File lib/rss/atom.rb, line 507
507:           def inline_text?
508:             !out_of_line? and [nil, "text", "html"].include?(@type)
509:           end

[Source]

     # File lib/rss/atom.rb, line 516
516:           def inline_xhtml?
517:             !out_of_line? and @type == "xhtml"
518:           end

[Source]

     # File lib/rss/atom.rb, line 558
558:           def mime_split
559:             media_type = subtype = nil
560:             if /\A\s*([a-z]+)\/([a-z\+]+)\s*(?:;.*)?\z/i =~ @type.to_s
561:               media_type = $1.downcase
562:               subtype = $2.downcase
563:             end
564:             [media_type, subtype]
565:           end

[Source]

     # File lib/rss/atom.rb, line 567
567:           def need_base64_encode?
568:             inline_other_base64?
569:           end

[Source]

     # File lib/rss/atom.rb, line 554
554:           def out_of_line?
555:             not @src.nil?
556:           end

[Source]

     # File lib/rss/atom.rb, line 483
483:           def xhtml
484:             if inline_xhtml?
485:               xml
486:             else
487:               nil
488:             end
489:           end

[Source]

     # File lib/rss/atom.rb, line 469
469:           def xml
470:             return @xml unless inline_xhtml?
471:             return @xml if @xml.nil?
472:             if @xml.is_a?(XML::Element) and
473:                 [@xml.name, @xml.uri] == ["div", XHTML_URI]
474:               return @xml
475:             end
476: 
477:             children = @xml
478:             children = [children] unless children.is_a?(Array)
479:             XML::Element.new("div", nil, XHTML_URI,
480:                              {"xmlns" => XHTML_URI}, children)
481:           end

Private Instance methods

[Source]

     # File lib/rss/atom.rb, line 572
572:           def empty_content?
573:             out_of_line? or super
574:           end

[Validate]