Sha256: 677fb0ffbb4b25652497c290a5a70c271e506e1b02d1ecbad3266cde47d06c0d

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 Bytes

Contents

require "spot/base"

module Spot
  class Song < Spot::Base
    attr_reader :length
    attr_writer :territory
    
    # Is valid if the territory exists or if no territory is given
    def valid?
      available?(@territory) or !@territory
    end
    
    def artist
      @_artist ||= Spot::Artist.new(@artists.first)
    end
    
    def album
      @_album ||= Spot::Album.new(@album)
    end
    
    def to_s
      "#{artist.name} - #{title}"
    end
    
    protected
      def territories
        @album["availability"]["territories"].split(" ")
      end
    
    alias_method :title, :name
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spot-2.0.4 lib/spot/song.rb
spot-2.0.1 lib/spot/song.rb
spot-2.0.0 lib/spot/song.rb