# frozen_string_literal: false
# The prefix for the Syndication XML namespace.
# The URI of the Syndication specification.
SY_URI = "http://purl.org/rss/1.0/modules/syndication/"
RDF.install_ns(SY_PREFIX, SY_URI)
def self.append_features(klass)
klass.install_must_call_validator(SY_PREFIX, SY_URI)
["updateFrequency", :positive_integer]
install_text_element(name, SY_URI, "?",
"#{SY_PREFIX}_#{name}", type,
%w(updateBase).each do |name|
install_date_element(name, SY_URI, "?",
"#{SY_PREFIX}_#{name}", 'w3cdtf',
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
alias_method(:_sy_updatePeriod=, :sy_updatePeriod=)
def sy_updatePeriod=(new_value)
new_value = new_value.strip
validate_sy_updatePeriod(new_value) if @do_validate
self._sy_updatePeriod = new_value
SY_UPDATEPERIOD_AVAILABLE_VALUES = %w(hourly daily weekly monthly yearly)
def validate_sy_updatePeriod(value) # :nodoc:
unless SY_UPDATEPERIOD_AVAILABLE_VALUES.include?(value)
raise NotAvailableValueError.new("updatePeriod", value)
class Channel; include SyndicationModel; end
prefix_size = SY_PREFIX.size + 1
SyndicationModel::ELEMENTS.uniq!
SyndicationModel::ELEMENTS.each do |full_name|
name = full_name[prefix_size..-1]
BaseListener.install_get_text_element(SY_URI, name, full_name)