Class: FileType::Generic
Direct Known Subclasses
Bz2, Directory, Gem, Gz, Ruby, Tar, TarBz2, TarGz, Unknown, Yaml, Zip
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Generic
Returns a new instance of Generic.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/file_type.rb', line 27
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
@base, @ext = $`, $&
if @ext.empty?
@base = self
else
@base = FileType.guess(@base)
end
end
|
Instance Attribute Details
Returns the value of attribute base.
25
26
27
|
# File 'lib/file_type.rb', line 25
def base
@base
end
|
Returns the value of attribute ext.
25
26
27
|
# File 'lib/file_type.rb', line 25
def ext
@ext
end
|
Returns the value of attribute path.
25
26
27
|
# File 'lib/file_type.rb', line 25
def path
@path
end
|
Class Method Details
68
69
70
71
|
# File 'lib/file_type.rb', line 68
def self. ( aCommand )
include Extractable
self.extract_command = aCommand
end
|
73
74
75
76
|
# File 'lib/file_type.rb', line 73
def self. ( aCommand )
include ExtractableDir
self.extract_command = aCommand
end
|
.filetype_extension(anObject, priority = 1) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/file_type.rb', line 86
def self.filetype_extension ( anObject, priority=1 )
class_eval do
self.extension = anObject
self.priority = priority
concrete
end
end
|
.inherited(klass) ⇒ Object
46
47
48
49
|
# File 'lib/file_type.rb', line 46
def self.inherited ( klass )
FileType.register(klass)
super
end
|
.match_type(path, max, best) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/file_type.rb', line 55
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
|
Instance Method Details
64
65
66
|
# File 'lib/file_type.rb', line 64
def + ( arg )
@path + arg.to_s
end
|
78
79
80
|
# File 'lib/file_type.rb', line 78
def
false
end
|
42
43
44
|
# File 'lib/file_type.rb', line 42
def extsplit
[@base, @ext]
end
|
#installable? ⇒ Boolean
82
83
84
|
# File 'lib/file_type.rb', line 82
def installable?
false
end
|
51
52
53
|
# File 'lib/file_type.rb', line 51
def to_s
@path.to_s
end
|