Class: Digestif::Hasher
- Inherits:
-
Object
- Object
- Digestif::Hasher
- Defined in:
- lib/digestif/hasher.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #digest ⇒ Object
-
#initialize(filename, options = CLI.default_options) ⇒ Hasher
constructor
A new instance of Hasher.
Constructor Details
#initialize(filename, options = CLI.default_options) ⇒ Hasher
Returns a new instance of Hasher.
9 10 11 12 |
# File 'lib/digestif/hasher.rb', line 9 def initialize(filename, = CLI.) self.filename = filename self. = end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
7 8 9 |
# File 'lib/digestif/hasher.rb', line 7 def filename @filename end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/digestif/hasher.rb', line 7 def end |
Instance Method Details
#digest ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/digestif/hasher.rb', line 14 def digest hasher = Digest.const_get(.digest.to_s.upcase).new File.open(filename, 'rb') do |f| until f.eof hasher.update(f.read(.read_size)) f.seek(.seek_size, IO::SEEK_CUR) end end hasher.hexdigest end |