Class: Ejaydj::Playlist

Inherits:
Object
  • Object
show all
Includes:
Mixins
Defined in:
lib/ejaydj/playlist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Playlist

Returns a new instance of Playlist.



14
15
16
# File 'lib/ejaydj/playlist.rb', line 14

def initialize(attributes={})
  instantiate_variables_from attributes
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/ejaydj/playlist.rb', line 8

def id
  @id
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/ejaydj/playlist.rb', line 8

def name
  @name
end

#number_of_tracksObject

Returns the value of attribute number_of_tracks.



8
9
10
# File 'lib/ejaydj/playlist.rb', line 8

def number_of_tracks
  @number_of_tracks
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/ejaydj/playlist.rb', line 8

def url
  @url
end

#user_idObject

Returns the value of attribute user_id.



8
9
10
# File 'lib/ejaydj/playlist.rb', line 8

def user_id
  @user_id
end

Instance Method Details

#next_trackObject



18
19
20
21
22
23
# File 'lib/ejaydj/playlist.rb', line 18

def next_track
  reload! if tracks.empty?
  track = tracks.pop
  track.playlist = self
  track
end

#reload!Object



29
30
31
# File 'lib/ejaydj/playlist.rb', line 29

def reload!
  @tracks = all_tracks
end

#tracksObject



25
26
27
# File 'lib/ejaydj/playlist.rb', line 25

def tracks
  @tracks ||= all_tracks
end