Class: MTP::FileSystem::Genres
- Inherits:
-
Object
- Object
- MTP::FileSystem::Genres
- Defined in:
- lib/mtp/fuse.rb
Instance Method Summary collapse
- #can_rmdir?(path) ⇒ Boolean
- #contents(path) ⇒ Object
- #directory?(path) ⇒ Boolean
- #dispatch(method, path, &block) ⇒ Object
- #file?(path) ⇒ Boolean
-
#initialize(device) ⇒ Genres
constructor
A new instance of Genres.
- #rmdir(path) ⇒ Object
- #size(path) ⇒ Object
Constructor Details
#initialize(device) ⇒ Genres
Returns a new instance of Genres.
255 256 257 |
# File 'lib/mtp/fuse.rb', line 255 def initialize(device) @device = device end |
Instance Method Details
#can_rmdir?(path) ⇒ Boolean
279 280 281 282 283 |
# File 'lib/mtp/fuse.rb', line 279 def can_rmdir?(path) dispatch(:can_rmdir?, path) do |path| !path.empty? end end |
#contents(path) ⇒ Object
293 294 295 296 297 |
# File 'lib/mtp/fuse.rb', line 293 def contents(path) dispatch(:contents, path) do |path| @device.tracks.map { |t| t.genre }.uniq end end |
#directory?(path) ⇒ Boolean
267 268 269 |
# File 'lib/mtp/fuse.rb', line 267 def directory?(path) path.size <= 3 end |
#dispatch(method, path, &block) ⇒ Object
259 260 261 262 263 264 265 |
# File 'lib/mtp/fuse.rb', line 259 def dispatch(method, path, &block) if path.size > 1 or (path.size == 1 and method == :contents) Artists.new(@device, path.shift).send(method, path) else yield path end end |
#file?(path) ⇒ Boolean
271 272 273 |
# File 'lib/mtp/fuse.rb', line 271 def file?(path) path.size == 4 end |
#rmdir(path) ⇒ Object
285 286 287 288 289 290 291 |
# File 'lib/mtp/fuse.rb', line 285 def rmdir(path) dispatch(:rmdir, path) do |path| @device.objects.each do |object| @device.delete(object) if object.is_a?(Track) and path.first == object.genre end end end |
#size(path) ⇒ Object
275 276 277 |
# File 'lib/mtp/fuse.rb', line 275 def size(path) @device[path.last].compressed_size end |