Class: AntiWordR::DocFileUrl

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

Overview

Handle a URI as a remote path to a PDF, extends PdfFile

Instance Attribute Summary

Attributes inherited from DocFile

#format, #path, #target

Instance Method Summary collapse

Methods inherited from DocFile

#convert, #convert_to_docbook, #convert_to_docbook_document

Constructor Details

#initialize(input_url, target_path = nil) ⇒ DocFileUrl

Returns a new instance of DocFileUrl.



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/antiwordr.rb', line 82

def initialize(input_url, target_path=nil)
  # check to make sure file is legit
  begin
    if ((input_url =~ URI::regexp).nil?)
      raise AntiWordRError, "invalid file url"
    end
    tempfile = Tempfile.new('antiwordr')
    File.open(tempfile.path, 'wb') {|f| f.write(open(input_url).read) }
    super(tempfile.path, target_path)
  rescue => bang
    raise AntiWordRError, bang.to_s
  end
end