Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/assetify/helpers.rb
Instance Method Summary collapse
-
#binary? ⇒ Boolean
From ptools - rdoc.info/gems/ptools/1.2.1/File.binary%3F.
Instance Method Details
#binary? ⇒ Boolean
From ptools - rdoc.info/gems/ptools/1.2.1/File.binary%3F
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/assetify/helpers.rb', line 8 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 |