Module: RSS::Atom::FeedHistory

Included in:
Feed
Defined in:
lib/rss/atom/feed_history.rb,
lib/rss/atom/feed_history/version.rb

Constant Summary collapse

PREFIX =
'fh'
URI =
'http://purl.org/syndication/history/1.0'
ELEMENTS =
[
  'complete',
  'archive'
]
PAGED_FEED_RELS =
['first', 'last', 'previous', 'next']
ARCHIVED_FEED_RELS =
['prev-archive', 'next-archive', 'current']
VERSION =
"0.0.4"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rss/atom/feed_history.rb', line 17

def included(klass)
  ELEMENTS.each do |name|
    full_name = "#{PREFIX}_#{name}"
    klass.install_must_call_validator PREFIX, URI
    klass.install_have_child_element name, URI, '?', full_name
    # This is a dirty redifinition. Should define writer type `:feed_history` and pass it to `install_have_child_element`?
    klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
      def #{full_name}_element(need_convert=true, indent='')
        if @#{full_name}
          Atom::FeedHistory::#{Utils.to_class_name(name)}.new.to_s(need_convert, indent)
        else
          ''
        end
      end
    EOC
  end
end

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rss/atom/feed_history.rb', line 44

def archived?
  !!fh_archive
end

#complete?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/rss/atom/feed_history.rb', line 36

def complete?
  !!fh_complete
end

#paged?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rss/atom/feed_history.rb', line 40

def paged?
  links.any? {|link| FeedHistory::PAGED_FEED_RELS.include? link.rel}
end