Class: PapermillAsset
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PapermillAsset
- Defined in:
- lib/papermill/papermill_asset.rb
Instance Method Summary collapse
- #content_type ⇒ Object
- #destroy_files ⇒ Object
- #height ⇒ Object
- #id_partition ⇒ Object
- #image? ⇒ Boolean
- #name ⇒ Object
- #size ⇒ Object
- #swfupload_file=(data) ⇒ Object
- #url(style = nil) ⇒ Object
- #width ⇒ Object
Instance Method Details
#content_type ⇒ Object
49 50 51 |
# File 'lib/papermill/papermill_asset.rb', line 49 def content_type file_content_type && file_content_type.split("/") end |
#destroy_files ⇒ Object
57 58 59 60 |
# File 'lib/papermill/papermill_asset.rb', line 57 def destroy_files system "rm -rf #{Papermill::papermill_interpolated_path({":id_partition" => self.id_partition}, ':id_partition')}/" true end |
#height ⇒ Object
37 38 39 |
# File 'lib/papermill/papermill_asset.rb', line 37 def height image? && Paperclip::Geometry.from_file(file).height end |
#id_partition ⇒ Object
25 26 27 |
# File 'lib/papermill/papermill_asset.rb', line 25 def id_partition ("%09d" % self.id).scan(/\d{3}/).join("/") end |
#image? ⇒ Boolean
53 54 55 |
# File 'lib/papermill/papermill_asset.rb', line 53 def image? content_type && content_type.first == "image" && content_type[1] end |
#name ⇒ Object
29 30 31 |
# File 'lib/papermill/papermill_asset.rb', line 29 def name file_file_name end |
#size ⇒ Object
41 42 43 |
# File 'lib/papermill/papermill_asset.rb', line 41 def size file_file_size end |
#swfupload_file=(data) ⇒ Object
20 21 22 23 |
# File 'lib/papermill/papermill_asset.rb', line 20 def swfupload_file=(data) data.content_type = MIME::Types.type_for(data.original_filename).to_s self.file = data end |
#url(style = nil) ⇒ Object
45 46 47 |
# File 'lib/papermill/papermill_asset.rb', line 45 def url(style = nil) file.url(style && CGI::escape(style.to_s)) end |
#width ⇒ Object
33 34 35 |
# File 'lib/papermill/papermill_asset.rb', line 33 def width image? && Paperclip::Geometry.from_file(file).width end |