Returns the file type from the modeline in file_name
# File lib/rdoc/parser.rb, line 140
def self.check_modeline file_name
line = open file_name do |io|
io.gets
end
/-\*-\s*(.*?\S)\s*-\*-/ =~ line
return nil unless type = $1
if /;/ =~ type then
return nil unless /(?:\s|\A)mode:\s*([^\s;]+)/ =~ type
type = $1
end
return nil if /coding:/ =~ type
type.downcase
rescue ArgumentError
rescue Encoding::InvalidByteSequenceError # invalid byte sequence
end