Class: Mixtape::RandomSongs

Inherits:
Object
  • Object
show all
Defined in:
lib/mixtape/random_songs.rb

Instance Method Summary collapse

Constructor Details

#initialize(sliced_songs) ⇒ RandomSongs

Returns a new instance of RandomSongs.



3
4
5
# File 'lib/mixtape/random_songs.rb', line 3

def initialize(sliced_songs)
  @sliced_songs = sliced_songs
end

Instance Method Details

#pick_by(number_per_section) ⇒ Object



7
8
9
10
11
# File 'lib/mixtape/random_songs.rb', line 7

def pick_by(number_per_section)
  @sliced_songs.map do |slice|
    slice.sample(number_per_section)
  end.flatten
end