Class: LoopermanSamples::Sample
- Inherits:
-
Object
- Object
- LoopermanSamples::Sample
- Defined in:
- lib/looperman_samples/sample.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#bpm ⇒ Object
Returns the value of attribute bpm.
-
#creator ⇒ Object
Returns the value of attribute creator.
-
#download_count ⇒ Object
Returns the value of attribute download_count.
-
#key ⇒ Object
Returns the value of attribute key.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .all ⇒ Object
- .list_samples_by_download_count ⇒ Object
- .list_samples_by_key ⇒ Object
- .list_samples_by_tempo ⇒ Object
- .sort_by_download_count ⇒ Object
- .sort_by_key ⇒ Object
- .sort_by_tempo ⇒ Object
Instance Method Summary collapse
-
#initialize(title = nil, creator = nil, genre = nil) ⇒ Sample
constructor
A new instance of Sample.
Constructor Details
#initialize(title = nil, creator = nil, genre = nil) ⇒ Sample
Returns a new instance of Sample.
13 14 15 16 17 |
# 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 |
Instance Attribute Details
#bpm ⇒ Object
Returns the value of attribute bpm.
6 7 8 |
# File 'lib/looperman_samples/sample.rb', line 6 def bpm @bpm end |
#creator ⇒ Object
Returns the value of attribute creator.
6 7 8 |
# File 'lib/looperman_samples/sample.rb', line 6 def creator @creator end |
#download_count ⇒ Object
Returns the value of attribute download_count.
6 7 8 |
# File 'lib/looperman_samples/sample.rb', line 6 def download_count @download_count end |
#key ⇒ Object
Returns the value of attribute key.
6 7 8 |
# File 'lib/looperman_samples/sample.rb', line 6 def key @key end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/looperman_samples/sample.rb', line 6 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/looperman_samples/sample.rb', line 6 def url @url end |
Class Method Details
.all ⇒ Object
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def self.all @@all end |
.list_samples_by_download_count ⇒ Object
50 51 52 53 54 55 |
# 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 ⇒ Object
28 29 30 31 32 33 |
# 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 ⇒ Object
39 40 41 42 43 44 |
# 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 |
.sort_by_download_count ⇒ Object
46 47 48 |
# 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 ⇒ Object
24 25 26 |
# 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 ⇒ Object
35 36 37 |
# 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 |