Class FileType::Generic
In: lib/file_type.rb
Parent: Object

Methods

Included Modules

Concrete

Attributes

base  [R] 
ext  [R] 
path  [R] 

Public Class methods

[Source]

# 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

[Source]

# File lib/file_type.rb, line 45
    def self.inherited ( klass )
      FileType.register(klass)
      super
    end

[Source]

# 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

[Source]

# 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

Public Instance methods

[Source]

# File lib/file_type.rb, line 63
    def + ( arg )
      @path + arg.to_s
    end

[Source]

# File lib/file_type.rb, line 67
    def extractable?
      false
    end

[Source]

# File lib/file_type.rb, line 41
    def extsplit
      [@base, @ext]
    end

[Source]

# File lib/file_type.rb, line 71
    def installable?
      false
    end

[Source]

# File lib/file_type.rb, line 37
    def symtbl_to_s
      to_s
    end

[Source]

# File lib/file_type.rb, line 50
    def to_s
      @path.to_s
    end

[Validate]