Sha256: e97de96ebd7388b12e15c98ac18b2e02cd55be095ad083533bb995168d1fd999
Contents?: true
Size: 422 Bytes
Versions: 4
Compression:
Stored size: 422 Bytes
Contents
class String # # Adapted ptools - http://rdoc.info/gems/ptools/1.2.1/File.binary%3F # def binary? #s = (File.read(file, File.stat(file).blksize) || "").split(//) s = (self[0..4096].force_encoding("binary") || "") #.split(//) ratio = s.gsub(/\d|\w|\s|[-~\.]/,'').size / s.size.to_f # if Opt[:debug] # print "Detecting #{s}" # puts "Ratio #{ratio}" # end ratio > 0.3 end end
Version data entries
4 entries across 4 versions & 1 rubygems