Class: Vera::Media

Inherits:
Object
  • Object
show all
Defined in:
lib/vera/media.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/vera/media.rb', line 7

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/vera/media.rb', line 7

def size
  @size
end

Instance Method Details

#filenameObject



14
15
16
# File 'lib/vera/media.rb', line 14

def filename
  File.basename(@path)
end

#partial_hashObject



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_hashObject



24
25
26
27
# File 'lib/vera/media.rb', line 24

def real_hash
  chunk = File.read(@path)
  Digest::SHA1.hexdigest(chunk)
end