Class: Attach::BlobTypes::File
- Inherits:
-
Object
- Object
- Attach::BlobTypes::File
- Defined in:
- lib/attach/blob_types/file.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #digest ⇒ Object
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #read ⇒ Object
- #size ⇒ Object
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
#file ⇒ Object (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
#digest ⇒ Object
22 23 24 |
# File 'lib/attach/blob_types/file.rb', line 22 def digest Digest::SHA1.file(@file.path).to_s end |
#read ⇒ Object
13 14 15 16 |
# File 'lib/attach/blob_types/file.rb', line 13 def read @file.rewind @file.read end |
#size ⇒ Object
18 19 20 |
# File 'lib/attach/blob_types/file.rb', line 18 def size @file.size end |