class Doc2Text::XmlBasedDocument::DocumentFile
Public Class Methods
Source
# File lib/doc2text/xml_based_document_file.rb, line 6 def initialize(document_path) @document_path = document_path end
Public Instance Methods
Source
# File lib/doc2text/xml_based_document_file.rb, line 26 def clean if File.exist?(extract_path) and contains_extracted_files? FileUtils.rm_r extract_path else puts 'Failed to clean temp files' end end
Source
# File lib/doc2text/xml_based_document_file.rb, line 22 def contains_extracted_files? false end
Source
# File lib/doc2text/xml_based_document_file.rb, line 39 def extract_extension 'unpacked' end
Source
# File lib/doc2text/xml_based_document_file.rb, line 43 def extract_path File.join File.dirname(@document_path), ".#{File.basename(@document_path)}_#{extract_extension}" end
Source
# File lib/doc2text/xml_based_document_file.rb, line 35 def open(filename) File.open File.join(extract_path, filename), 'r' end
Open file from the current odt
Source
# File lib/doc2text/xml_based_document_file.rb, line 10 def unpack Zip::File.open(@document_path) { |zip_file| Dir.mkdir(extract_path) zip_file.each do |entry| zipped_file_extract_path = File.join extract_path, entry.name FileUtils.mkdir_p File.dirname(zipped_file_extract_path) zip_file.extract entry, zipped_file_extract_path end } end