Sha256: 6777ee761d026608e02262aafa3556b1bc6cbb34e166fcf086fe49b3033c9f66
Contents?: true
Size: 541 Bytes
Versions: 12
Compression:
Stored size: 541 Bytes
Contents
class RssParser require 'rexml/document' def self.run(url) xml = REXML::Document.new Net::HTTP.get(URI.parse(url)) data = { :title => xml.root.elements['channel/title'].text, :home_url => xml.root.elements['channel/link'].text, :rss_url => url, :items => [] } xml.elements.each '//item' do |item| new_items = {} and item.elements.each do |e| new_items[e.name.gsub(/^dc:(\w)/,"\1").to_sym] = e.text end data[:items] << new_items end data end end
Version data entries
12 entries across 12 versions & 1 rubygems