class Spotify::Charts::TrackParser

Attributes

attributes[R]

Public Class Methods

new(attributes) click to toggle source
# File lib/spotify/charts/track_parser.rb, line 9
def initialize(attributes)
  @attributes = attributes
end

Public Instance Methods

track() click to toggle source
# File lib/spotify/charts/track_parser.rb, line 13
def track
  Track.new.tap do |t|
    t.date = Date.parse(attributes['date'])
    t.country = attributes['country']
    t.track_url = URI(attributes['track_url'])
    t.track_name = attributes['track_name']
    t.artist_name = attributes['artist_name']
    t.artist_url = URI(attributes['artist_url'])
    t.album_name = attributes['album_name']
    t.album_url = URI(attributes['album_url'])
    t.artwork_url = URI(attributes['artwork_url'])
    t.num_streams = attributes['num_streams']
  end
end