- gzipped = filetype =~ /gzip compressed/
- bzipped = filetype =~ /bzip2 compressed/
- zipped = filetype =~ /Zip archive/
- tarred = filetype =~ /tar archive/
-
- extension = if tarred && gzipped
- ".tar.gz"
- elsif tarred && bzipped
- ".tar.bz2"
- elsif tarred
- ".tar"
- elsif gzipped
- ".gpx.gz"
- elsif bzipped
- ".gpx.bz2"
- elsif zipped
- ".zip"
- else
- ".gpx"
- end
-
- extension
+ gzipped = filetype.include?("gzip compressed")
+ bzipped = filetype.include?("bzip2 compressed")
+ zipped = filetype.include?("Zip archive")
+ tarred = filetype.include?("tar archive")
+
+ if tarred && gzipped
+ ".tar.gz"
+ elsif tarred && bzipped
+ ".tar.bz2"
+ elsif tarred
+ ".tar"
+ elsif gzipped
+ ".gpx.gz"
+ elsif bzipped
+ ".gpx.bz2"
+ elsif zipped
+ ".zip"
+ else
+ ".gpx"
+ end