Sha256: bd3269d557c053c5151e52594de7f6f21e7bc2c7e1cad32b2ebed11330c036d2

Contents?: true

Size: 674 Bytes

Versions: 4

Compression:

Stored size: 674 Bytes

Contents

require "spot/base"

module SpotContainer
  class Song < SpotContainer::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 ||= SpotContainer::Artist.new(@artists.first)
    end
    
    def album
      @_album ||= SpotContainer::Album.new(@album)
    end
    
    def to_s
      @_to_s = "#{title} - #{artist.name}"
    end
    
    protected
      def territories
        @_territories ||= @album["availability"]["territories"].split(" ")
      end
    
    alias_method :title, :name
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spot-0.1.4 lib/spot/song.rb
spot-0.1.3 lib/spot/song.rb
spot-0.1.2 lib/spot/song.rb
spot-0.1.1 lib/spot/song.rb