Class: Paperclip::DocumentProcessor
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::DocumentProcessor
- Defined in:
- lib/paperclip/document.rb
Overview
Main processor
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#tmp_dir ⇒ Object
readonly
Returns the value of attribute tmp_dir.
Instance Method Summary collapse
- #basename ⇒ Object
- #file_path ⇒ Object
-
#initialize(file, options = {}, attachment = nil) ⇒ DocumentProcessor
constructor
A new instance of DocumentProcessor.
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ DocumentProcessor
Returns a new instance of DocumentProcessor.
11 12 13 14 15 16 17 |
# File 'lib/paperclip/document.rb', line 11 def initialize(file, = {}, = nil) super(file, , ) @instance = @attachment.instance # @tmp_dir = Pathname.new(Dir.tmpdir).join("paperclip-document", instance.class.name, attachment.name.to_s, basename, Time.now.to_i.to_s(36) + "-" + rand(1_000_000).to_s(36)) # @tmp_dir = Rails.root.join("paperclip-document", instance.class.name, attachment.name.to_s, basename, Time.now.to_i.to_s(36) + "-" + rand(1_000_000).to_s(36)) @tmp_dir = Pathname.new(Dir.tmpdir).join("paperclip-document-" + rand(1_000_000_000).to_s(36) + "-" + rand(1_000_000).to_s(36) + "-" + Time.now.to_i.to_s(36) + "-" + rand(1_000_000).to_s(36)) end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
9 10 11 |
# File 'lib/paperclip/document.rb', line 9 def instance @instance end |
#tmp_dir ⇒ Object (readonly)
Returns the value of attribute tmp_dir.
9 10 11 |
# File 'lib/paperclip/document.rb', line 9 def tmp_dir @tmp_dir end |
Instance Method Details
#basename ⇒ Object
23 24 25 |
# File 'lib/paperclip/document.rb', line 23 def basename file_path.basename.to_s.gsub(/\.[^\.]+/, '') end |
#file_path ⇒ Object
19 20 21 |
# File 'lib/paperclip/document.rb', line 19 def file_path Pathname.new(@file.path) end |