| Class | FileType::Generic |
| In: |
lib/file_type.rb
|
| Parent: | Object |
| base | [R] | |
| ext | [R] | |
| path | [R] |
# File lib/file_type.rb, line 75 def self.filetype_extension ( anObject, priority=1 ) class_eval do self.extension = anObject self.priority = priority include Concrete end end
# File lib/file_type.rb, line 54 def self.match_type ( path, max, best ) ext_re = self.extension if path.to_s =~ ext_re cur = $&.size * self.priority return [cur, self] if cur > max end return [max, best] end
# File lib/file_type.rb, line 22 def initialize ( path ) @path = Pathname.new(path) re = self.class.extension raise ArgumentError, "bad class #{self.class}" if re.nil? unless @path.to_s =~ re raise ArgumentError, "#{@path} do not match /#{re.source}/" end b, @ext = $`, $& if @ext.empty? @base = self else @base = FileType.guess(b) end end