Sha256: 933d81b6adac94dfb3e2e9a2098bf62037eaffaa2f1d310a00902d9ceb0a77bf

Contents?: true

Size: 393 Bytes

Versions: 1

Compression:

Stored size: 393 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)
    myStat = stat(name)
    return false unless myStat.file?
    open(name) do |file|
      blk = file.read(myStat.blksize)
      return blk.size == 0 ||
        blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vim_printer-0.1.4 lib/vim_printer/core_ext/file.rb