Class: Bazuro::Pdf2docx

Inherits:
Object
  • Object
show all
Defined in:
lib/bazuro.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf) ⇒ Pdf2docx

Returns a new instance of Pdf2docx.



18
19
20
21
22
# File 'lib/bazuro.rb', line 18

def initialize(pdf)
  @pdf = pdf
  @docx = nil
  @docname = nil
end

Instance Attribute Details

#docnameObject

Returns the value of attribute docname.



16
17
18
# File 'lib/bazuro.rb', line 16

def docname
  @docname
end

#docxObject

Returns the value of attribute docx.



16
17
18
# File 'lib/bazuro.rb', line 16

def docx
  @docx
end

#pdfObject

Returns the value of attribute pdf.



16
17
18
# File 'lib/bazuro.rb', line 16

def pdf
  @pdf
end

Instance Method Details

#convert(path = Bazuro.config["local"]["temp_path"]) ⇒ Object



40
41
42
43
44
# File 'lib/bazuro.rb', line 40

def convert(path = Bazuro.config["local"]["temp_path"])
  @docname = @pdf.split('/').last.gsub(".pdf", ".docx")
  @docx = "#{path}/#{@docname}"
  system("cd #{path} && #{Bazuro.config["local"]["winword_path"]} /mPDF2DOC /q #{@pdf}")
end

#requestObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bazuro.rb', line 24

def request
  RestClient::Request.new(
      :method => :post,
      :url => Bazuro.config["remote"]["url"],
      :user => Bazuro.config["remote"]["username"],
      :password => Bazuro.config["remote"]["password"],
      :payload => {
          :file => @pdf
      }
  ).execute
end

#testObject



36
37
38
# File 'lib/bazuro.rb', line 36

def test

end