Class: Vera::Media
- Inherits:
-
Object
- Object
- Vera::Media
- Defined in:
- lib/vera/media.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(path) ⇒ Media
constructor
A new instance of Media.
- #partial_hash ⇒ Object
- #real_hash ⇒ Object
Constructor Details
#initialize(path) ⇒ Media
Returns a new instance of Media.
9 10 11 12 |
# File 'lib/vera/media.rb', line 9 def initialize(path) @path = path size = File.size(@path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/vera/media.rb', line 7 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/vera/media.rb', line 7 def size @size end |
Instance Method Details
#filename ⇒ Object
14 15 16 |
# File 'lib/vera/media.rb', line 14 def filename File.basename(@path) end |
#partial_hash ⇒ Object
18 19 20 21 22 |
# File 'lib/vera/media.rb', line 18 def partial_hash chunk_size = 1024 * 5 chunk = File.read(@path, chunk_size) Digest::SHA1.hexdigest(chunk) end |
#real_hash ⇒ Object
24 25 26 27 |
# File 'lib/vera/media.rb', line 24 def real_hash chunk = File.read(@path) Digest::SHA1.hexdigest(chunk) end |