Class: Ektoplayer::Operations::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/ektoplayer/operations/browser.rb

Instance Method Summary collapse

Constructor Details

#initialize(operations, browser, playlist) ⇒ Browser

Operations for Model::Browser:

enter

see

back

see

add_to_playlist

see



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ektoplayer/operations/browser.rb', line 8

def initialize(operations, browser, playlist)
   register = operations.with_register('browser.')
   register.(:back,   &browser.method(:back))

   register.(:enter) do |index|
      unless browser.enter(index)
         tracks = browser.tracks(index)
         playlist.add(*tracks)
         operations.send(:'playlist.play', playlist.size - tracks.size)
      end
   end
         
   register.(:add_to_playlist) do |index|
      tracks = browser.tracks(index)
      playlist.add(*tracks)
   end
end