Class: PapermillAsset

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/papermill/papermill_asset.rb

Instance Method Summary collapse

Instance Method Details

#content_typeObject



42
43
44
# File 'lib/papermill/papermill_asset.rb', line 42

def content_type
  file_content_type && file_content_type.split("/")
end

#destroy_filesObject



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_partitionObject



26
27
28
# File 'lib/papermill/papermill_asset.rb', line 26

def id_partition
  ("%09d" % self.id).scan(/\d{3}/).join("/")
end

#image?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/papermill/papermill_asset.rb', line 46

def image?
  content_type && content_type.first == "image" && content_type[1]
end

#nameObject



30
31
32
# File 'lib/papermill/papermill_asset.rb', line 30

def name
  file_file_name
end

#sizeObject



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