Class: Mumbletune::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/mumbletune/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, tracks, description) ⇒ Collection

Returns a new instance of Collection.



12
13
14
15
16
17
# File 'lib/mumbletune/collection.rb', line 12

def initialize(type, tracks, description)
	@type = type
	@description = description
	@tracks = [tracks].flatten
	@history = Array.new
end

Instance Attribute Details

#current_trackObject

Returns the value of attribute current_track.



8
9
10
# File 'lib/mumbletune/collection.rb', line 8

def current_track
  @current_track
end

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/mumbletune/collection.rb', line 8

def description
  @description
end

#historyObject

Returns the value of attribute history.



8
9
10
# File 'lib/mumbletune/collection.rb', line 8

def history
  @history
end

#tracksObject

Returns the value of attribute tracks.



8
9
10
# File 'lib/mumbletune/collection.rb', line 8

def tracks
  @tracks
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/mumbletune/collection.rb', line 8

def type
  @type
end

#userObject

Returns the value of attribute user.



8
9
10
# File 'lib/mumbletune/collection.rb', line 8

def user
  @user
end

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/mumbletune/collection.rb', line 33

def any?
	!empty?
end

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/mumbletune/collection.rb', line 27

def empty?
	without_current = @tracks.dup
	without_current.delete_if { |t| t == @current_track }
	without_current.empty?
end

#nextObject



19
20
21
22
23
24
25
# File 'lib/mumbletune/collection.rb', line 19

def next
	if @current_track
		@history << @current_track
		@tracks.delete @current_track
	end
	@current_track = @tracks.first
end