Class: Attach::BlobTypes::File

Inherits:
Object
  • Object
show all
Defined in:
lib/attach/blob_types/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ File

Returns a new instance of File.



9
10
11
# File 'lib/attach/blob_types/file.rb', line 9

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/attach/blob_types/file.rb', line 7

def file
  @file
end

Instance Method Details

#digestObject



22
23
24
# File 'lib/attach/blob_types/file.rb', line 22

def digest
  Digest::SHA1.file(@file.path).to_s
end

#readObject



13
14
15
16
# File 'lib/attach/blob_types/file.rb', line 13

def read
  @file.rewind
  @file.read
end

#sizeObject



18
19
20
# File 'lib/attach/blob_types/file.rb', line 18

def size
  @file.size
end