channel.rb 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # frozen_string_literal: true
  2. class RSS::Channel < RSS::Element
  3. def initialize
  4. super()
  5. @root = create_element('channel')
  6. end
  7. def title(str)
  8. append_element('title', str)
  9. end
  10. def link(str)
  11. append_element('link', str)
  12. end
  13. def last_build_date(date)
  14. append_element('lastBuildDate', date.to_fs(:rfc822))
  15. end
  16. def image(url, title, link)
  17. append_element('image') do |image|
  18. image << create_element('url', url)
  19. image << create_element('title', title)
  20. image << create_element('link', link)
  21. end
  22. end
  23. def description(str)
  24. append_element('description', str)
  25. end
  26. def generator(str)
  27. append_element('generator', str)
  28. end
  29. def icon(str)
  30. append_element('webfeeds:icon', str)
  31. end
  32. def logo(str)
  33. append_element('webfeeds:logo', str)
  34. end
  35. def item(&block)
  36. @root << RSS::Item.with(&block)
  37. end
  38. end