Class: TestServer::Checksum

Inherits:
Object
  • Object
show all
Defined in:
lib/test_server/checksum.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm: nil, prefix: nil, data: nil, engine: nil) ⇒ Checksum

Returns a new instance of Checksum



6
7
8
9
10
11
# File 'lib/test_server/checksum.rb', line 6

def initialize(algorithm: nil, prefix: nil, data: nil, engine: nil)
  @algorithm = algorithm
  @prefix    = prefix
  @engine    = engine
  @data      = data
end

Instance Attribute Details

#algorithmObject (readonly)

Returns the value of attribute algorithm



4
5
6
# File 'lib/test_server/checksum.rb', line 4

def algorithm
  @algorithm
end

#dataObject (readonly)

Returns the value of attribute data



4
5
6
# File 'lib/test_server/checksum.rb', line 4

def data
  @data
end

#engineObject (readonly)

Returns the value of attribute engine



4
5
6
# File 'lib/test_server/checksum.rb', line 4

def engine
  @engine
end

#prefixObject (readonly)

Returns the value of attribute prefix



4
5
6
# File 'lib/test_server/checksum.rb', line 4

def prefix
  @prefix
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/test_server/checksum.rb', line 17

def to_s
  "#{prefix} #{value}"
end

#valueObject



13
14
15
# File 'lib/test_server/checksum.rb', line 13

def value
  engine.hexdigest data.to_s
end