Class: S3Light::Md5Calculator

Inherits:
Object
  • Object
show all
Defined in:
lib/s3-light/md5_calculator.rb

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Md5Calculator

Returns a new instance of Md5Calculator.



5
6
7
# File 'lib/s3-light/md5_calculator.rb', line 5

def initialize(input)
  @input = input
end

Instance Method Details

#inspectObject



23
24
25
# File 'lib/s3-light/md5_calculator.rb', line 23

def inspect
  "#<#{self.class.name}>"
end

#md5Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/s3-light/md5_calculator.rb', line 9

def md5
  @md5 ||=
    case @input
    when String
      Digest::MD5.hexdigest(@input)
    when IO, StringIO
      compute_md5_for_io
    when Pathname
      compute_md5_for_file_path
    else
      raise ArgumentError, "Unsupported input type: #{@input.class}"
    end
end