Class: Paperclip::DocsplitText
Instance Attribute Summary
#attachment, #options, #src
Instance Method Summary
collapse
#initialize, #src_path
Instance Method Details
#destination_file ⇒ Object
28
29
30
|
# File 'lib/processors/docsplit_text.rb', line 28
def destination_file
File.open(File.join(@dst_path, "#{@basename}.txt"))
end
|
#full_text ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/processors/docsplit_text.rb', line 32
def full_text
full_text = String.new
destination_file.each do |line|
full_text += line
end
full_text
end
|
#make ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/processors/docsplit_text.rb', line 3
def make
begin
@dst_path = Dir.tmpdir
@pages = @options[:pages] || [1]
@options = @options.merge(:output => @dst_path)
Docsplit.(src_path, @options)
rescue Exception => e
raise Paperclip::Error, "There was an error extracting text from #{@basename}"
end
if @options[:full_text_column]
ar_model = @attachment.instance
ar_model[@options[:full_text_column]] = full_text
ar_model.run_callbacks(:save) { false }
end
destination_file
end
|