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
468
469
470
471
472
473
474
475
476
477
478
479
480
|
# File 'lib/rss/atom.rb', line 468
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
448
449
450
|
# File 'lib/rss/atom.rb', line 448
def xml_getter
"xml"
end
|
.xml_setter ⇒ Object
444
445
446
|
# File 'lib/rss/atom.rb', line 444
def xml_setter
"xml="
end
|
Instance Method Details
#atom_validate(ignore_unknown_element, tags, uri) ⇒ Object
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
|
# File 'lib/rss/atom.rb', line 490
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
464
465
466
|
# File 'lib/rss/atom.rb', line 464
def have_xml_content?
inline_xhtml? or inline_other_xml?
end
|
#inline_html? ⇒ Boolean
510
511
512
513
|
# File 'lib/rss/atom.rb', line 510
def inline_html?
return false if out_of_line?
@type == "html" or mime_split == ["text", "html"]
end
|
#inline_other? ⇒ Boolean
519
520
521
522
523
524
|
# File 'lib/rss/atom.rb', line 519
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
549
550
551
|
# File 'lib/rss/atom.rb', line 549
def inline_other_base64?
inline_other? and !inline_other_text? and !inline_other_xml?
end
|
#inline_other_text? ⇒ Boolean
526
527
528
529
530
531
532
533
|
# File 'lib/rss/atom.rb', line 526
def inline_other_text?
return false unless inline_other?
return false if inline_other_xml?
media_type, subtype = mime_split
return true if "text" == media_type.downcase
false
end
|
#inline_other_xml? ⇒ Boolean
535
536
537
538
539
540
541
542
543
544
545
546
547
|
# File 'lib/rss/atom.rb', line 535
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
506
507
508
|
# File 'lib/rss/atom.rb', line 506
def inline_text?
!out_of_line? and [nil, "text", "html"].include?(@type)
end
|
#inline_xhtml? ⇒ Boolean
515
516
517
|
# File 'lib/rss/atom.rb', line 515
def inline_xhtml?
!out_of_line? and @type == "xhtml"
end
|
#mime_split ⇒ Object
557
558
559
560
561
562
563
564
|
# File 'lib/rss/atom.rb', line 557
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
566
567
568
|
# File 'lib/rss/atom.rb', line 566
def need_base64_encode?
inline_other_base64?
end
|
#out_of_line? ⇒ Boolean
553
554
555
|
# File 'lib/rss/atom.rb', line 553
def out_of_line?
not @src.nil?
end
|
#xhtml ⇒ Object
482
483
484
485
486
487
488
|
# File 'lib/rss/atom.rb', line 482
def xhtml
if inline_xhtml?
xml
else
nil
end
end
|