Class: Spot::Song

Inherits:
Base
  • Object
show all
Defined in:
lib/spot/song.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#available?, #href, #initialize, #popularity

Constructor Details

This class inherits a constructor from Spot::Base

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



5
6
7
# File 'lib/spot/song.rb', line 5

def length
  @length
end

#territory=(value) ⇒ Object (writeonly)

Sets the attribute territory

Parameters:

  • value

    the value to set the attribute territory to.



6
7
8
# File 'lib/spot/song.rb', line 6

def territory=(value)
  @territory = value
end

Instance Method Details

#albumObject



17
18
19
# File 'lib/spot/song.rb', line 17

def album
  @_album ||= Spot::Album.new(@album)
end

#artistObject



13
14
15
# File 'lib/spot/song.rb', line 13

def artist
  @_artist ||= Spot::Artist.new(@artists.first)
end

#to_sObject



21
22
23
# File 'lib/spot/song.rb', line 21

def to_s
  "#{artist.name} - #{title}"
end

#valid?Boolean

Is valid if the territory exists or if no territory is given

Returns:

  • (Boolean)


9
10
11
# File 'lib/spot/song.rb', line 9

def valid?
  available?(@territory) or !@territory
end