class RSS::Atom::Feed

定义 Atom Feed 文档的顶层元素。它由若干个子 Entry 元素组成,并具有以下属性:

  • author

  • categories

  • category

  • content

  • contributor

  • entries (别名为 items)

  • entry

  • generator

  • icon

  • id

  • link

  • logo

  • rights

  • subtitle

  • title

  • updated

参考:validator.w3.org/feed/docs/rfc4287.html#element.feed

公共类方法

new(version=nil, encoding=nil, standalone=nil) 点击以切换源代码

创建一个新的 Atom feed

调用父类方法 RSS::RootElementMixin::new
# File rss-0.3.1/lib/rss/atom.rb, line 313
def initialize(version=nil, encoding=nil, standalone=nil)
  super("1.0", version, encoding, standalone)
  @feed_type = "atom"
  @feed_subtype = "feed"
end

公共实例方法

have_author?() 点击以切换源代码

如果 feed 中存在任何作者,或者任何子 Entry 元素拥有作者,则返回 true

# File rss-0.3.1/lib/rss/atom.rb, line 323
def have_author?
  authors.any? {|author| !author.to_s.empty?} or
    entries.any? {|entry| entry.have_author?(false)}
end

私有实例方法

atom_validate(ignore_unknown_element, tags, uri) 点击以切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 329
def atom_validate(ignore_unknown_element, tags, uri)
  unless have_author?
    raise MissingTagError.new("author", tag_name)
  end
  validate_duplicate_links(links)
end
have_required_elements?() 点击以切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 336
def have_required_elements?
  super and have_author?
end
maker_target(maker) 点击以切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 340
def maker_target(maker)
  maker.channel
end
setup_maker_element(channel) 点击以切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 344
def setup_maker_element(channel)
  prev_dc_dates = channel.dc_dates.to_a.dup
  super
  channel.about = id.content if id
  channel.dc_dates.replace(prev_dc_dates)
end
setup_maker_elements(channel) 点击以切换源代码
# File rss-0.3.1/lib/rss/atom.rb, line 351
def setup_maker_elements(channel)
  super
  items = channel.maker.items
  entries.each do |entry|
    entry.setup_maker(items)
  end
end