Class: Filezor::File

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#md5Object

Returns the value of attribute md5.



4
5
6
# File 'lib/filezor/file.rb', line 4

def md5
  @md5
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/filezor/file.rb', line 4

def path
  @path
end

#tempfileObject

Returns the value of attribute tempfile.



4
5
6
# File 'lib/filezor/file.rb', line 4

def tempfile
  @tempfile
end