Class: RFuseFlacToMovFS
- Inherits:
-
Object
- Object
- RFuseFlacToMovFS
- Defined in:
- lib/rfuse_flac_to_mov_fs.rb
Overview
require ‘pp’
Instance Method Summary collapse
- #contents(path) ⇒ Object
- #directory?(path) ⇒ Boolean
- #file?(path) ⇒ Boolean
-
#initialize(options) ⇒ RFuseFlacToMovFS
constructor
A new instance of RFuseFlacToMovFS.
- #read_file(path) ⇒ Object
- #size(path) ⇒ Object
Constructor Details
#initialize(options) ⇒ RFuseFlacToMovFS
Returns a new instance of RFuseFlacToMovFS.
29 30 31 32 |
# File 'lib/rfuse_flac_to_mov_fs.rb', line 29 def initialize( ) puts "#{__FILE__} initialize( #{.input} )" @base_dir = .input end |
Instance Method Details
#contents(path) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rfuse_flac_to_mov_fs.rb', line 34 def contents(path) n_path = File.( @base_dir + path ) Dir.chdir(n_path) # TODO # Currently just return a list of files we need to search and replace /.flac$/.mov/i files = Dir.glob('*') #Added command to OS X Finder not to index. #files << 'metadata_never_index' # incase esensitive match files.each do |x| x.gsub!(/\.flac$/i, ".mov") puts x end return files end |
#directory?(path) ⇒ Boolean
64 65 66 |
# File 'lib/rfuse_flac_to_mov_fs.rb', line 64 def directory?(path) File.directory?(@base_dir + path) end |
#file?(path) ⇒ Boolean
54 55 56 57 58 59 60 61 62 |
# File 'lib/rfuse_flac_to_mov_fs.rb', line 54 def file?(path) #If path ends with metadata_never_index it is a file #if path =~ /metadata_never_index$/ # return true #end #Need method which checks for .flac or jut not directory and everything is a file return (not File.directory?( @base_dir + path )) end |
#read_file(path) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/rfuse_flac_to_mov_fs.rb', line 68 def read_file(path) input = path.dup if File.exists?( @base_dir + input) return File.new(@base_dir + input , "r").read end # mmm replacment was not case sensitive so we do not actually # know the correct case of the file extension # NB: the most popular format of HFS+ (mac drives) is not case sensitive # so these should resolve correctly for now if input =~ /\.mov$/ input['.mov'] = '.flac' end #puts "read file #{path}" if File.exists?( @base_dir + input) return File.new(@base_dir + input , "r").read end return "ERROR, file not found\n" end |
#size(path) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rfuse_flac_to_mov_fs.rb', line 92 def size(path) puts "size( #{path}" input = path.dup if File.exists?( @base_dir + path ) return File.size( @base_dir + path ) end if input =~ /\.mov$/ puts " Converting from mov to flac" input['.mov'] = '.flac' end if File.exists?( @base_dir + input ) return File.size( @base_dir + input ) else return 16 end end |