class LoopermanSamples::Sample

Attributes

bpm[RW]
creator[RW]
download_count[RW]
key[RW]
title[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/looperman_samples/sample.rb, line 9
def self.all
  @@all
end
list_samples_by_download_count() click to toggle source
# File lib/looperman_samples/sample.rb, line 50
def self.list_samples_by_download_count
  sort_by_download_count.each_with_index do |item, index|
    #get rid of this! puts shouldn't be in sample class
    puts "#{index + 1}." + " #{item.title}" + " - #{item.download_count} downloads"
  end
end
list_samples_by_key() click to toggle source
# File lib/looperman_samples/sample.rb, line 28
def self.list_samples_by_key
  sort_by_key.each_with_index do |item, index|
    #get rid of this! puts shouldn't be in sample class
    puts "#{index + 1}." + " #{item.title} - " + "#{item.key}"
  end
end
list_samples_by_tempo() click to toggle source
# File lib/looperman_samples/sample.rb, line 39
def self.list_samples_by_tempo
  sort_by_tempo.each_with_index do |item, index|
    #get rid of this! puts shouldn't be in sample class
    puts "#{index + 1}." + " #{item.title}" + "- #{item.bpm}"
  end
end
new(title = nil, creator = nil, genre = nil) click to toggle source
# File lib/looperman_samples/sample.rb, line 13
def initialize(title = nil, creator = nil, genre = nil)
  @title = title
  self.creator = creator if creator
  self.genre = genre if genre
end
sort_by_download_count() click to toggle source
# File lib/looperman_samples/sample.rb, line 46
def self.sort_by_download_count
  all.sort{|a, b| b.download_count.to_i <=> a.download_count.to_i}
end
sort_by_key() click to toggle source
# File lib/looperman_samples/sample.rb, line 24
def self.sort_by_key
  all.sort{|a, b| a.key <=> b.key}
end
sort_by_tempo() click to toggle source
# File lib/looperman_samples/sample.rb, line 35
def self.sort_by_tempo
  all.sort{|a, b| b.bpm.to_i <=> a.bpm.to_i}
end

Public Instance Methods

creator=(creator) click to toggle source
# File lib/looperman_samples/sample.rb, line 19
def creator=(creator)
  @creator = creator
  creator.add_sample(self)
end