Sha256: 854c9109d01085b8bac3e0623c17d02b6953f48eecdc96cad3f032dcc3d45046
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require 'open-uri' require 'simple-rss' module Stratify module Rhapsody class Query attr_reader :rss_url def initialize(rss_url) @rss_url = rss_url end def activities raw_activities.map {|raw_activity| build_activity_from_raw_data(raw_activity)} end private def raw_activities initialize_simple_rss_to_import_rhapsody_tags rss = SimpleRSS.parse open(rss_url) rss.items end def build_activity_from_raw_data(raw_activity) Stratify::Rhapsody::Activity.new({ :track_id => raw_activity[:"rhap_track-rcid"], :track_title => raw_activity[:rhap_track], :artist_id => raw_activity[:"rhap_artist-rcid"], :artist_name => raw_activity[:rhap_artist], :album_id => raw_activity[:"rhap_album-rcid"], :album_title => raw_activity[:rhap_album], :genre => raw_activity[:category], :created_at => raw_activity[:pubDate] }) end def initialize_simple_rss_to_import_rhapsody_tags SimpleRSS.item_tags << :"rhap:track-rcid" << :"rhap:track" << :"rhap:artist-rcid" << :"rhap:artist"<< :"rhap:album-rcid" << :"rhap:album" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stratify-rhapsody-0.1.3 | lib/stratify-rhapsody/query.rb |
stratify-rhapsody-0.1.2 | lib/stratify-rhapsody/query.rb |
stratify-rhapsody-0.1.0 | lib/stratify-rhapsody/query.rb |