Class: FileUploader::Resource
- Inherits:
-
Object
- Object
- FileUploader::Resource
show all
- Includes:
- S3Resource
- Defined in:
- lib/resource/resource.rb
Constant Summary
Constants included
from S3Resource
S3Resource::S3_BUCKET, S3Resource::S3_CONFIG, S3Resource::S3_KEY, S3Resource::S3_SECRET
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from S3Resource
#destroy_s3, #send
Constructor Details
#initialize(resource) ⇒ Resource
Returns a new instance of Resource.
19
20
21
|
# File 'lib/resource/resource.rb', line 19
def initialize(resource)
@file = resource
end
|
Instance Attribute Details
#tempfile ⇒ Object
Returns the value of attribute tempfile.
9
10
11
|
# File 'lib/resource/resource.rb', line 9
def tempfile
@tempfile
end
|
Class Method Details
.create(resource) ⇒ Object
Instance Method Details
#destroy ⇒ Object
41
42
43
44
45
|
# File 'lib/resource/resource.rb', line 41
def destroy
FileUtils.rm(self.tempfile)
end
|
#extension ⇒ Object
23
24
25
|
# File 'lib/resource/resource.rb', line 23
def extension
self.uri.chomp.downcase.gsub(/.*\./o, '')
end
|
#mime_type(uri) ⇒ Object
35
36
37
38
39
|
# File 'lib/resource/resource.rb', line 35
def mime_type(uri)
clean_uri = uri.split("?").first
MIME::Types.type_for(clean_uri).first
end
|
#path ⇒ Object
27
28
29
|
# File 'lib/resource/resource.rb', line 27
def path
@file.path
end
|
#uri ⇒ Object
31
32
33
|
# File 'lib/resource/resource.rb', line 31
def uri
@file
end
|