Class: Ektoplayer::Models::Browser
- Inherits:
-
Model
- Object
- Model
- Ektoplayer::Models::Browser
show all
- Defined in:
- lib/ektoplayer/models/browser.rb
Defined Under Namespace
Classes: BrowsableCollection, BrowserRoot
Constant Summary
collapse
- PARENT_DIRECTORY =
'..'.freeze
- PATHS =
{
artist: [:artist].freeze,
album: [:album ].freeze,
style: [:style ].freeze,
year: [:year ].freeze,
title: [].freeze
}.freeze
Instance Attribute Summary
Attributes inherited from Model
#events
Instance Method Summary
collapse
Constructor Details
#initialize(client) ⇒ Browser
Returns a new instance of Browser.
16
17
18
19
20
21
|
# File 'lib/ektoplayer/models/browser.rb', line 16
def initialize(client)
super()
@events.register(:changed)
@stack = []
@stack << BrowserRoot.new(client.database)
end
|
Instance Method Details
#back ⇒ Object
44
45
46
47
48
49
|
# File 'lib/ektoplayer/models/browser.rb', line 44
def back
return false unless @stack.size > 1
@stack.pop
@events.trigger(:changed)
true
end
|
#current ⇒ Object
23
24
25
|
# File 'lib/ektoplayer/models/browser.rb', line 23
def current
@stack[-1]
end
|
#enter(index) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/ektoplayer/models/browser.rb', line 36
def enter(index)
return false unless (sub = current.enter(index))
return back() if sub == :parent
@stack.push(sub)
@events.trigger(:changed)
true
end
|
#reload ⇒ Object
31
32
33
34
|
# File 'lib/ektoplayer/models/browser.rb', line 31
def reload
current.reload
@events.trigger(:changed)
end
|
#tracks(index) ⇒ Object
27
28
29
|
# File 'lib/ektoplayer/models/browser.rb', line 27
def tracks(index)
current.tracks(index)
end
|