Class: Mixtape::Source::Base
- Inherits:
-
Object
- Object
- Mixtape::Source::Base
show all
- Defined in:
- lib/mixtape/source/base.rb
Defined Under Namespace
Classes: NotImplementedError
Instance Method Summary
collapse
Constructor Details
#initialize(number_of_songs) ⇒ Base
Returns a new instance of Base.
6
7
8
9
10
11
|
# File 'lib/mixtape/source/base.rb', line 6
def initialize(number_of_songs)
@number_of_songs = number_of_songs
if pages_ids.length != number_of_songs
raise(ArgumentError, 'Number of songs must equal the number of pages')
end
end
|
Instance Method Details
#pages_ids ⇒ Object
19
20
21
|
# File 'lib/mixtape/source/base.rb', line 19
def pages_ids
(1..@number_of_songs).to_a
end
|
#songs ⇒ Object
13
14
15
16
17
|
# File 'lib/mixtape/source/base.rb', line 13
def songs
sliced_songs = pages_ids.pmap{ |id| songs_for_page_id(id) }
random_songs = Mixtape::RandomSongs.new(sliced_songs)
random_songs.pick_by(1)
end
|
#songs_for_page_id(id) ⇒ Object
23
24
25
|
# File 'lib/mixtape/source/base.rb', line 23
def songs_for_page_id(id)
raise NotImplementedError
end
|