模块 RSS::Atom::TextConstruct
TextConstruct
模块用于定义文本构造 Atom
元素,该元素用于存储少量人类可读文本。
TextConstruct
有一个类型属性,例如 text、html、xhtml
属性
xhtml[W]
公共类方法
append_features(klass) 点击切换源代码
调用超类方法
# File rss-0.3.1/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
xml_getter() 点击切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 116 def xml_getter "xhtml" end
xml_setter() 点击切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 120 def xml_setter "xhtml=" end
公共实例方法
atom_validate(ignore_unknown_element, tags, uri) 点击切换源代码
如果元素的格式不正确,则引发 MissingTagError
或 NotExpectedTagError
。
# File rss-0.3.1/lib/rss/atom.rb, line 150 def atom_validate(ignore_unknown_element, tags, 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
have_xml_content?() 点击切换源代码
如果类型为“xhtml”,则返回 true。
# File rss-0.3.1/lib/rss/atom.rb, line 144 def have_xml_content? @type == "xhtml" end
xhtml() 点击切换源代码
返回或构建 XHTML 内容。
# File rss-0.3.1/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
私有实例方法
maker_target(target) 点击切换源代码
# File rss-0.3.1/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) 点击切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 166 def setup_maker_attributes(target) target.type = type target.content = content target.xml_content = @xhtml end