Sha256: b1b5f6c389199af15cdffc22c89b67975e24068ade28b14a31195a057d4eef23

Contents?: true

Size: 609 Bytes

Versions: 27

Compression:

Stored size: 609 Bytes

Contents

# frozen_string_literal: true

require "digest/sha2"
require "murmurhash3"

module Mihari
  class HTML
    attr_reader :path

    def initialize(path)
      @path = path
    end

    def exists?
      return false unless path

      File.exist? path
    end

    def sha256
      Digest::SHA256.hexdigest data
    end

    def md5
      Digest::MD5.hexdigest data
    end

    def mmh3
      hash = MurmurHash3::V32.str_hash(data)
      if (hash & 0x80000000).zero?
        hash
      else
        -((hash ^ 0xFFFFFFFF) + 1)
      end
    end

    private

    def data
      File.read path
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
mihari-2.4.0 lib/mihari/html.rb
mihari-2.3.1 lib/mihari/html.rb
mihari-2.3.0 lib/mihari/html.rb
mihari-2.2.1 lib/mihari/html.rb
mihari-2.2.0 lib/mihari/html.rb
mihari-2.1.0 lib/mihari/html.rb
mihari-2.0.0 lib/mihari/html.rb
mihari-1.5.1 lib/mihari/html.rb
mihari-1.5.0 lib/mihari/html.rb
mihari-1.4.1 lib/mihari/html.rb
mihari-1.4.0 lib/mihari/html.rb
mihari-1.3.2 lib/mihari/html.rb
mihari-1.3.1 lib/mihari/html.rb
mihari-1.3.0 lib/mihari/html.rb
mihari-1.2.1 lib/mihari/html.rb
mihari-1.2.0 lib/mihari/html.rb
mihari-1.1.1 lib/mihari/html.rb
mihari-1.1.0 lib/mihari/html.rb
mihari-1.0.1 lib/mihari/html.rb
mihari-1.0.0 lib/mihari/html.rb