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.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# 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
|
Instance Attribute Details
Returns the value of attribute base.
20
21
22
|
# File 'lib/file_type.rb', line 20
def base
@base
end
|
Returns the value of attribute ext.
20
21
22
|
# File 'lib/file_type.rb', line 20
def ext
@ext
end
|
Returns the value of attribute path.
20
21
22
|
# File 'lib/file_type.rb', line 20
def path
@path
end
|
Class Method Details
.filetype_extension(anObject, priority = 1) ⇒ Object
75
76
77
78
79
80
81
|
# 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
|
.inherited(klass) ⇒ Object
45
46
47
48
|
# File 'lib/file_type.rb', line 45
def self.inherited ( klass )
FileType.register(klass)
super
end
|
.match_type(path, max, best) ⇒ Object
54
55
56
57
58
59
60
61
|
# 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
|
Instance Method Details
63
64
65
|
# File 'lib/file_type.rb', line 63
def + ( arg )
@path + arg.to_s
end
|
67
68
69
|
# File 'lib/file_type.rb', line 67
def
false
end
|
41
42
43
|
# File 'lib/file_type.rb', line 41
def extsplit
[@base, @ext]
end
|
#installable? ⇒ Boolean
71
72
73
|
# File 'lib/file_type.rb', line 71
def installable?
false
end
|
#symtbl_to_s ⇒ Object
37
38
39
|
# File 'lib/file_type.rb', line 37
def symtbl_to_s
to_s
end
|
50
51
52
|
# File 'lib/file_type.rb', line 50
def to_s
@path.to_s
end
|