Class: Rant::Signature::MD5
Instance Method Summary collapse
-
#initialize(rac) ⇒ MD5
constructor
A new instance of MD5.
- #name ⇒ Object
- #signature_for_dir(dirname) ⇒ Object
- #signature_for_file(filename) ⇒ Object
- #signature_for_io(io) ⇒ Object
- #signature_for_string(str) ⇒ Object
Constructor Details
#initialize(rac) ⇒ MD5
Returns a new instance of MD5.
16 17 18 |
# File 'lib/rant/import/signature/md5.rb', line 16 def initialize(rac) #@rac = rac end |
Instance Method Details
#name ⇒ Object
19 20 21 |
# File 'lib/rant/import/signature/md5.rb', line 19 def name "md5" end |
#signature_for_dir(dirname) ⇒ Object
25 26 27 28 29 |
# File 'lib/rant/import/signature/md5.rb', line 25 def signature_for_dir(dirname) entries = Dir.entries(dirname) entries.sort! signature_for_string(entries.join << entries.size.to_s) end |
#signature_for_file(filename) ⇒ Object
22 23 24 |
# File 'lib/rant/import/signature/md5.rb', line 22 def signature_for_file(filename) signature_for_string(File.read(filename)) end |
#signature_for_io(io) ⇒ Object
30 31 32 |
# File 'lib/rant/import/signature/md5.rb', line 30 def signature_for_io(io) signature_for_string(io.read) end |
#signature_for_string(str) ⇒ Object
33 34 35 |
# File 'lib/rant/import/signature/md5.rb', line 33 def signature_for_string(str) Digest::MD5.hexdigest(str) end |