Module: RSS::Atom::TextConstruct

Included in:
Feed::Entry::Summary, Feed::Rights, Feed::Subtitle, Feed::Title
Defined in:
lib/rss/atom.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xhtmlObject



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/rss/atom.rb', line 111

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

Class Method Details

.append_features(klass) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/rss/atom.rb', line 86

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 Method Details

#atom_validate(ignore_unknown_element, tags, uri) ⇒ Object



128
129
130
131
132
133
134
135
136
137
# File 'lib/rss/atom.rb', line 128

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?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/rss/atom.rb', line 124

def have_xml_content?
  @type == "xhtml"
end