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
- #id_partition ⇒ Object
- #image? ⇒ Boolean
- #name ⇒ Object
- #size ⇒ Object
- #swfupload_file=(data) ⇒ Object
- #url(style = nil) ⇒ Object
Instance Method Details
#content_type ⇒ Object
42 43 44 |
# File 'lib/papermill/papermill_asset.rb', line 42 def content_type file_content_type && file_content_type.split("/") end |
#destroy_files ⇒ Object
50 51 52 53 |
# File 'lib/papermill/papermill_asset.rb', line 50 def destroy_files system "rm -rf #{Papermill::papermill_interpolated_path({":id_partition" => self.id_partition}, ':id_partition')}/" true end |
#id_partition ⇒ Object
26 27 28 |
# File 'lib/papermill/papermill_asset.rb', line 26 def id_partition ("%09d" % self.id).scan(/\d{3}/).join("/") end |
#image? ⇒ Boolean
46 47 48 |
# File 'lib/papermill/papermill_asset.rb', line 46 def image? content_type && content_type.first == "image" && content_type[1] end |
#name ⇒ Object
30 31 32 |
# File 'lib/papermill/papermill_asset.rb', line 30 def name file_file_name end |
#size ⇒ Object
34 35 36 |
# File 'lib/papermill/papermill_asset.rb', line 34 def size file_file_size end |
#swfupload_file=(data) ⇒ Object
21 22 23 24 |
# File 'lib/papermill/papermill_asset.rb', line 21 def swfupload_file=(data) data.content_type = MIME::Types.type_for(data.original_filename).to_s self.file = data end |
#url(style = nil) ⇒ Object
38 39 40 |
# File 'lib/papermill/papermill_asset.rb', line 38 def url(style = nil) file.url(style && CGI::escape(style.to_s)) end |