Module: RSS::Atom::TextConstruct
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/rss/atom.rb |
Overview
The TextConstruct module is used to define a Text construct ::RSS::Atom element, which is used to store small quantities of human-readable text.
The TextConstruct has a type attribute, e.g. text, html, xhtml
Reference: validator.w3.org/feed/docs/rfc4287.html#text.constructs
Class Method Summary
Instance Attribute Summary
-
#xhtml
rw
Returns or builds the XHTML content.
- #xhtml=(value) rw
-
#have_xml_content? ⇒ Boolean
readonly
Returns true if type is “xhtml”.
Instance Method Summary
-
#atom_validate(ignore_unknown_element, tags, uri)
Raises a ::RSS::MissingTagError or ::RSS::NotExpectedTagError if the element is not properly formatted.
- #maker_target(target) private
- #setup_maker_attributes(target) private
Class Method Details
.append_features(klass)
[ GitHub ]# File 'lib/rss/atom.rb', line 103
def self.append_features(klass) super klass.class_eval do [ ["type", ""], ].each do |name, uri, required| install_get_attribute(name, uri, required, :text_type) end content_setup add_need_initialize_variable("xhtml") class << self def xml_getter "xhtml" end def xml_setter "xhtml=" end end end end
Instance Attribute Details
#have_xml_content? ⇒ Boolean
(readonly)
Returns true if type is “xhtml”.
# File 'lib/rss/atom.rb', line 144
def have_xml_content? @type == "xhtml" end
#xhtml (rw)
Returns or builds the XHTML content.
# File 'lib/rss/atom.rb', line 130
def xhtml return @xhtml if @xhtml.nil? if @xhtml.is_a?(XML::Element) and [@xhtml.name, @xhtml.uri] == ["div", XHTML_URI] return @xhtml end children = @xhtml children = [children] unless children.is_a?(Array) XML::Element.new("div", nil, XHTML_URI, {"xmlns" => XHTML_URI}, children) end
#xhtml=(value) (rw)
[ GitHub ]# File 'lib/rss/atom.rb', line 127
attr_writer :xhtml
Instance Method Details
#atom_validate(ignore_unknown_element, tags, uri)
Raises a ::RSS::MissingTagError or ::RSS::NotExpectedTagError if the element is not properly formatted.
# File 'lib/rss/atom.rb', line 150
def atom_validate(ignore_unknown_element, , uri) if have_xml_content? if @xhtml.nil? raise MissingTagError.new("div", tag_name) end unless [@xhtml.name, @xhtml.uri] == ["div", XHTML_URI] raise NotExpectedTagError.new(@xhtml.name, @xhtml.uri, tag_name) end end end
#maker_target(target) (private)
[ GitHub ]# File 'lib/rss/atom.rb', line 162
def maker_target(target) target.__send__(self.class.name.split(/::/).last.downcase) {|x| x} end
#setup_maker_attributes(target) (private)
[ GitHub ]# File 'lib/rss/atom.rb', line 166
def setup_maker_attributes(target) target.type = type target.content = content target.xml_content = @xhtml end