Class: Mumbletune::Collection
- Inherits:
-
Object
- Object
- Mumbletune::Collection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/mumbletune/collection.rb
Instance Attribute Summary collapse
-
#current_track ⇒ Object
Returns the value of attribute current_track.
-
#description ⇒ Object
Returns the value of attribute description.
-
#history ⇒ Object
Returns the value of attribute history.
-
#tracks ⇒ Object
Returns the value of attribute tracks.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #any? ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(type, tracks, description) ⇒ Collection
constructor
A new instance of Collection.
- #next ⇒ Object
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_track ⇒ Object
Returns the value of attribute current_track.
8 9 10 |
# File 'lib/mumbletune/collection.rb', line 8 def current_track @current_track end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/mumbletune/collection.rb', line 8 def description @description end |
#history ⇒ Object
Returns the value of attribute history.
8 9 10 |
# File 'lib/mumbletune/collection.rb', line 8 def history @history end |
#tracks ⇒ Object
Returns the value of attribute tracks.
8 9 10 |
# File 'lib/mumbletune/collection.rb', line 8 def tracks @tracks end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/mumbletune/collection.rb', line 8 def type @type end |
#user ⇒ Object
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
33 34 35 |
# File 'lib/mumbletune/collection.rb', line 33 def any? !empty? end |
#empty? ⇒ 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 |
#next ⇒ Object
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 |