Class: RSS::Atom::Feed::Entry::Content
Constant Summary
Constants included
from CommonModel
CommonModel::ELEMENTS, CommonModel::NSPOOL
Constants inherited
from Element
Element::GET_ATTRIBUTES, Element::HAVE_CHILDREN_ELEMENTS, Element::INDENT, Element::MODELS, Element::MUST_CALL_VALIDATORS, Element::NEED_INITIALIZE_VARIABLES, Element::PLURAL_FORMS, Element::TO_ELEMENT_METHODS
Instance Attribute Summary collapse
Attributes inherited from Element
#do_validate, #parent
Class Method Summary
collapse
Instance Method Summary
collapse
append_features
Methods inherited from Element
add_have_children_element, add_need_initialize_variable, add_plural_form, add_to_element_method, content_setup, #convert, #converter=, def_corresponded_attr_reader, def_corresponded_attr_writer, #full_name, get_attributes, have_children_elements, have_content?, inherited, inherited_base, #initialize, install_get_attribute, install_model, install_must_call_validator, install_ns, models, must_call_validators, need_initialize_variables, need_parent?, plural_forms, required_prefix, required_uri, #set_next_element, tag_name, #tag_name, to_element_methods, #to_s, #valid?, #validate, #validate_for_stream
Methods included from BaseModel
#install_date_element, #install_have_child_element, #install_have_children_element, #install_text_element
Methods included from Utils
element_initialize_arguments?, get_file_and_line_from_caller, html_escape, new_with_value_if_need, to_class_name
#inherited_array_reader, #inherited_hash_reader, #inherited_reader
Methods included from SetupMaker
#setup_maker
Constructor Details
This class inherits a constructor from RSS::Element
Instance Attribute Details
#xml ⇒ Object
553
554
555
556
557
558
559
560
561
562
563
564
565
|
# 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
|
Class Method Details
.xml_getter ⇒ Object
533
534
535
|
# File 'lib/rss/atom.rb', line 533
def xml_getter
"xml"
end
|
.xml_setter ⇒ Object
529
530
531
|
# File 'lib/rss/atom.rb', line 529
def xml_setter
"xml="
end
|
Instance Method Details
#atom_validate(ignore_unknown_element, tags, uri) ⇒ Object
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
# 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
|
#have_xml_content? ⇒ Boolean
549
550
551
|
# File 'lib/rss/atom.rb', line 549
def have_xml_content?
inline_xhtml? or inline_other_xml?
end
|
#inline_html? ⇒ Boolean
595
596
597
598
|
# 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
604
605
606
607
608
609
|
# 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
634
635
636
|
# 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
611
612
613
614
615
616
617
618
|
# 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
620
621
622
623
624
625
626
627
628
629
630
631
632
|
# 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
591
592
593
|
# File 'lib/rss/atom.rb', line 591
def inline_text?
!out_of_line? and [nil, "text", "html"].include?(@type)
end
|
#inline_xhtml? ⇒ Boolean
600
601
602
|
# File 'lib/rss/atom.rb', line 600
def inline_xhtml?
!out_of_line? and @type == "xhtml"
end
|
#mime_split ⇒ Object
642
643
644
645
646
647
648
649
|
# 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
|
#need_base64_encode? ⇒ Boolean
651
652
653
|
# File 'lib/rss/atom.rb', line 651
def need_base64_encode?
inline_other_base64?
end
|
#out_of_line? ⇒ Boolean
638
639
640
|
# File 'lib/rss/atom.rb', line 638
def out_of_line?
not @src.nil?
end
|
#xhtml ⇒ Object
567
568
569
570
571
572
573
|
# File 'lib/rss/atom.rb', line 567
def xhtml
if inline_xhtml?
xml
else
nil
end
end
|