Class: Rockbox::Api::Browse
- Inherits:
-
Object
- Object
- Rockbox::Api::Browse
- Defined in:
- lib/rockbox/api/browse.rb
Instance Method Summary collapse
- #directories(path = nil) ⇒ Object
- #entries(path = nil) ⇒ Array<Rockbox::Entry>
- #files(path = nil) ⇒ Object
-
#initialize(http) ⇒ Browse
constructor
A new instance of Browse.
Constructor Details
#initialize(http) ⇒ Browse
Returns a new instance of Browse.
8 9 10 |
# File 'lib/rockbox/api/browse.rb', line 8 def initialize(http) @http = http end |
Instance Method Details
#directories(path = nil) ⇒ Object
22 23 24 |
# File 'lib/rockbox/api/browse.rb', line 22 def directories(path = nil) entries(path).select { |e| Rockbox.directory?(e) } end |
#entries(path = nil) ⇒ Array<Rockbox::Entry>
14 15 16 17 18 19 20 |
# File 'lib/rockbox/api/browse.rb', line 14 def entries(path = nil) data = @http.execute( "query Browse($path: String) { treeGetEntries(path: $path) { name attr timeWrite customaction displayName } }", path ? { path: path } : nil ) Array(data[:tree_get_entries]).map { |e| Entry.from_hash(e) } end |
#files(path = nil) ⇒ Object
26 27 28 |
# File 'lib/rockbox/api/browse.rb', line 26 def files(path = nil) entries(path).reject { |e| Rockbox.directory?(e) } end |