I am trying to use the Ruby RSS library to build an RSS feed for a podcast. I am supplying values for an enclosure, but the enclosure is not being added to the feed and fails silently.
What do I need to do in order for the enclosure to be included in the feed item?
rss = RSS::Maker.make("atom") do |maker|
maker.channel.id = "my_channel"
maker.channel.updated = Time.now.to_s
maker.channel.author = "me"
maker.channel.title = "my channel"
maker.items.new_item do |item|
item.title = "my episode"
item.id = "my_episode"
item.updated = Time.now.to_s
item.enclosure.url = "https://example.com"
item.enclosure.type = "audio/mpeg"
item.enclosure.length = 123
end
end
Output:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<author>
<name>me</name>
</author>
<id>my_channel</id>
<title>my channel</title>
<updated>2024-05-11T12:09:06+01:00</updated>
<entry>
<id>my_episode</id>
<title>my episode</title>
<updated>2024-05-11T12:09:06+01:00</updated>
<dc:date>2024-05-11T12:09:06+01:00</dc:date>
</entry>
<dc:date>2024-05-11T12:09:06+01:00</dc:date>
</feed>