class Spinna::MusicLibrary
This class encapsulates the access to the music library.
Attributes
config[R]
history[R]
Public Class Methods
new(config, history)
click to toggle source
# File lib/spinna/music_library.rb, line 4 def initialize(config, history) @config = config @history = history end
Public Instance Methods
pickable_albums(pattern = nil)
click to toggle source
Returns the albums that are pickable. An album is pickable if it isn’t present in the history log. If a pattern is given, then only the albums that match the pattern will be returned.
# File lib/spinna/music_library.rb, line 12 def pickable_albums(pattern = nil) return available_albums unless pattern available_albums.select! { |a| a =~ Regexp.new(pattern)} end
Private Instance Methods
albums()
click to toggle source
# File lib/spinna/music_library.rb, line 22 def albums Dir.entries(config.source_dir).reject! { |i| i =~ /\A\./ } end
available_albums()
click to toggle source
Returns only the albums that are available for selection.
# File lib/spinna/music_library.rb, line 32 def available_albums albums - previously_selected_albums end
previously_selected_albums()
click to toggle source
Returns the list of previously selected albums.
# File lib/spinna/music_library.rb, line 27 def previously_selected_albums history.log end