summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-15 19:57:50 +0200
committerhut <hut@lavabit.com>2009-06-15 19:57:50 +0200
commitcecde3a6c41e529d74615de0ced0b4f34d87caa9 (patch)
treeb912adc91ca0e5e800a44097a7de2b4050a82c78
parent05727a149600a8559345f6283eb523ac13dd1ccd (diff)
downloadranger-cecde3a6c41e529d74615de0ced0b4f34d87caa9.tar.gz
add video? audio? image? methods to Directory::Entry
i have also added aliases for backward compatibility
-rw-r--r--code/entry.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/code/entry.rb b/code/entry.rb
index 7a17bb65..0582c280 100644
--- a/code/entry.rb
+++ b/code/entry.rb
@@ -27,7 +27,6 @@ class Directory::Entry
 			@basename = File.basename(dirname)
 		end
 		@name, @ext = @basename.split_at_last_dot
-		@movie = MOVIE_EXTENSIONS.include?(@ext)
 		@size = 0
 		@exists = false
 		@rights = '----------'
@@ -55,12 +54,16 @@ class Directory::Entry
 	def marked?() @marked end
 	def symlink?() @symlink end
 	def socket?() @type == :socket end
-	def movie?() @movie end
+	def video?() @video ||= @mimetype && @mimetype =~ /^video\// end
+	def audio?() @sound ||= @mimetype && @mimetype =~ /^audio\// end
+	def image?() @image ||= @mimetype && @mimetype =~ /^image\// end
 	def broken_symlink?() @symlink and !@exists end
 	def dir?() @type == :dir end
 	def file?() @type == :file end
 	def writable?() @writable end
 	def executable?() @executable end
+	alias movie? video?
+	alias sound? audio?
 
 	def handler()
 		## get_handler has to be defined in another file