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

Version Path
typus-0.9.39 lib/vendor/rss_parser.rb
typus-0.9.38 lib/vendor/rss_parser.rb
typus-0.9.37 lib/vendor/rss_parser.rb
typus-0.9.36 lib/vendor/rss_parser.rb
typus-0.9.35 lib/vendor/rss_parser.rb
typus-0.9.34 lib/vendor/rss_parser.rb
typus-0.9.33 lib/vendor/rss_parser.rb
typus-0.9.32 lib/vendor/rss_parser.rb
typus-0.9.31 lib/vendor/rss_parser.rb
typus-0.9.30 lib/vendor/rss_parser.rb
typus-0.9.29 lib/vendor/rss_parser.rb
typus-0.9.28 lib/vendor/rss_parser.rb