class Playa::TrackCollection

Attributes

args[R]

Public Class Methods

new(args = []) click to toggle source
# File lib/playa/models/track_collection.rb, line 3
def initialize(args = [])
  @args = args
end

Public Instance Methods

files() click to toggle source
# File lib/playa/models/track_collection.rb, line 14
def files
  @_files ||= Dir.glob(recursive).select do |file|
    File.file?(file) && File.extname(file) == '.mp3'
  end
end
tracks() click to toggle source
# File lib/playa/models/track_collection.rb, line 7
def tracks
  @_tracks ||= files.reduce([]) do |acc, file|
    acc << Track.new(file)
    acc
  end
end

Private Instance Methods

directory() click to toggle source
# File lib/playa/models/track_collection.rb, line 28
def directory
  args.first || '.'
end
recursive() click to toggle source
# File lib/playa/models/track_collection.rb, line 24
def recursive
  directory + '/**/*'
end