Class: Filezor::File
- Inherits:
-
Object
- Object
- Filezor::File
- Defined in:
- lib/filezor/file.rb
Overview
A File that knows its MD5 hash, and target upload path.
Defined Under Namespace
Modules: Pathable
Instance Attribute Summary collapse
-
#md5 ⇒ Object
Returns the value of attribute md5.
-
#path ⇒ Object
Returns the value of attribute path.
-
#tempfile ⇒ Object
Returns the value of attribute tempfile.
Instance Method Summary collapse
-
#initialize(tempfile, path, hash = nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(tempfile, path, hash = nil) ⇒ File
Returns a new instance of File.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/filezor/file.rb', line 10 def initialize(tempfile, path, hash = nil) @tempfile = tempfile # for ruby 1.9 compat. Restclient duck-types files on path @tempfile.extend(Pathable) unless @tempfile.respond_to?(:path) && @tempfile.respond_to?(:path=) @tempfile.path ||= path @path = path @md5 = hash || Filezor::Util::md5(tempfile) end |
Instance Attribute Details
#md5 ⇒ Object
Returns the value of attribute md5.
4 5 6 |
# File 'lib/filezor/file.rb', line 4 def md5 @md5 end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/filezor/file.rb', line 4 def path @path end |
#tempfile ⇒ Object
Returns the value of attribute tempfile.
4 5 6 |
# File 'lib/filezor/file.rb', line 4 def tempfile @tempfile end |