Class: Nevzorov::Generator
- Inherits:
-
Object
- Object
- Nevzorov::Generator
- Defined in:
- lib/nevzorov/generator.rb
Overview
Generates podcast feed
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(*args) ⇒ Object
8 9 10 |
# File 'lib/nevzorov/generator.rb', line 8 def call(*args) new.call(*args) end |
Instance Method Details
#add_categories(feed_xml, names) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/nevzorov/generator.rb', line 22 def add_categories(feed_xml, names) feed_xml.xpath('rss/channel/item/author').each do |item| names.each do |name| category = Nokogiri::XML::Node.new('itunes:category', feed_xml) category['text'] = name item.add_next_sibling(category) end end end |
#call(url, image, categories, file) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/nevzorov/generator.rb', line 13 def call(url, image, categories, file) source = Net::HTTP.get(URI(url)) xml = Nokogiri.XML(source) replace_image(xml, image) add_categories(xml, categories) IO.write(file, xml) end |