Class: Mihari::HTML

Inherits:
Object
  • Object
show all
Defined in:
lib/mihari/html.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ HTML

Returns a new instance of HTML.



10
11
12
# File 'lib/mihari/html.rb', line 10

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/mihari/html.rb', line 8

def path
  @path
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/mihari/html.rb', line 14

def exists?
  return false unless path

  File.exist? path
end

#md5Object



24
25
26
# File 'lib/mihari/html.rb', line 24

def md5
  Digest::MD5.hexdigest data
end

#mmh3Object



28
29
30
31
32
33
34
35
# File 'lib/mihari/html.rb', line 28

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

#sha256Object



20
21
22
# File 'lib/mihari/html.rb', line 20

def sha256
  Digest::SHA256.hexdigest data
end