Harbor Documentation

Public Class Methods

generators()

      # File lib/harbor/checksum.rb, line 9
 9:   def self.generators
10:     @generators ||= Harbor::Container.new
11:   end

new(algorithm, file)

      # File lib/harbor/checksum.rb, line 17
17:   def initialize(algorithm, file)
18:     @algorithm = algorithm
19:     @file = file
20:   end

register(algorithm, generator_class, &block)

      # File lib/harbor/checksum.rb, line 13
13:   def self.register(algorithm, generator_class, &block)
14:     generators.register("#{algorithm}_checksum_generator", generator_class, &block)
15:   end

Public Instance Methods

hex()

      # File lib/harbor/checksum.rb, line 22
22:   def hex
23:     raise FileNotFoundError unless File.file?(@file.path)
24: 
25:     @generator ||= self.class.generators.get("#{@algorithm}_checksum_generator")
26:     @generator.compute(@file.path.to_s)
27:   end
Also aliased as: to_s

inspect()

      # File lib/harbor/checksum.rb, line 35
35:   def inspect
36:     "#<#{self.class}: \"#{to_s}\">"
37:   end

to_i()

      # File lib/harbor/checksum.rb, line 31
31:   def to_i
32:     hex.to_i(16)
33:   end

to_s()

Alias for hex