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
extend Concerns::Findable responsible for knowing about all of the samples.
-
#creator ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples.
-
#download_count ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples.
-
#genre ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples.
-
#key ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples.
-
#title ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples.
-
#url ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples.
Class Method Summary collapse
- .all ⇒ Object
- .list_samples_by_download_count ⇒ Object
- .list_samples_by_key ⇒ Object
- .list_samples_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.
16 17 18 19 20 |
# File 'lib/looperman_samples/sample.rb', line 16 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
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def bpm @bpm end |
#creator ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def creator @creator end |
#download_count ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def download_count @download_count end |
#genre ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def genre @genre end |
#key ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def key @key end |
#title ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def title @title end |
#url ⇒ Object
extend Concerns::Findable responsible for knowing about all of the samples
9 10 11 |
# File 'lib/looperman_samples/sample.rb', line 9 def url @url end |
Class Method Details
.all ⇒ Object
12 13 14 |
# File 'lib/looperman_samples/sample.rb', line 12 def self.all @@all end |
.list_samples_by_download_count ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/looperman_samples/sample.rb', line 48 def self.list_samples_by_download_count #sort the samples by download count and return as a numbered list samples_sorted_by_download_count = LoopermanSamples::Sample.all.sort {|a, b| b.download_count.to_i <=> a.download_count.to_i} samples_sorted_by_download_count.each_with_index do |item, index| puts "#{index + 1}." + " #{item.title}" + " - #{item.download_count} downloads" end end |
.list_samples_by_key ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/looperman_samples/sample.rb', line 32 def self.list_samples_by_key #sort the samples by key and return as a numbered list samples_sorted_by_key = LoopermanSamples::Sample.all.sort {|a, b| a.key <=> b.key} samples_sorted_by_key.each_with_index do |item, index| puts "#{index + 1}." + " #{item.title} - " + "#{item.key}" end end |
.list_samples_by_tempo ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/looperman_samples/sample.rb', line 40 def self.list_samples_by_tempo #sort the samples by tempo(bpm) and return as a numbered list samples_sorted_by_tempo = LoopermanSamples::Sample.all.sort {|a, b| b.bpm.to_i <=> a.bpm.to_i} samples_sorted_by_tempo.each_with_index do |item, index| puts "#{index + 1}." + " #{item.title}" + "- #{item.bpm}" end end |