Sha256: 143ab18fea3967790e49c24fb7bb658fc0082a2a3e7b588d9d7c41b4f0bb22a9

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Grooveshark
  class Song
    attr_reader :data
    attr_reader :id, :artist_id, :album_id
    attr_reader :name, :artist, :album, :track
    attr_reader :duraion, :artwork, :playcount
  
    def initialize(data=nil)
      unless data.nil?
        @data       = data
        @id         = data['SongID']
        @name       = data['SongName'] || data['Name']
        @artist     = data['ArtistName']
        @artist_id  = data['ArtistID']
        @album      = data['AlbumName']
        @album_id   = data['AlbumID']
        @track      = data['TrackNum']
        @duration   = data['EstimateDuration']
        @artwork    = data['CoverArtFilename']
        @playcount  = data['SongPlays']
      end
    end
    
    def to_s
      [@id, @name, @artist].join(' - ')
    end
    
    def to_hash
      {
        'songID'      => @id,
        'songName'    => @name,
        'artistName'  => @artist,
        'artistID'    => @artist_id,
        'albumName'   => @album,
        'albumID'     => @album_id,
        'track'       => @track
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grooveshark-0.1.1 lib/grooveshark/song.rb