Sha256: d91bc74bc83d58570370a83594026bcf370aed454b6be6ab159832dcaf0dce93
Contents?: true
Size: 396 Bytes
Versions: 2
Compression:
Stored size: 396 Bytes
Contents
# From: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/44936 class File def self.binary?(name) name = File.expand_path(name) my_stat = stat(name) return false unless my_stat.file? open(name) do |file| blk = file.read(my_stat.blksize) return blk.size == 0 || blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vim_printer-0.1.6 | lib/vim_printer/core_ext/file.rb |
vim_printer-0.1.5 | lib/vim_printer/core_ext/file.rb |