class Docx2TXT::Docx
Public Class Methods
new(location)
click to toggle source
# File lib/docx2txt.rb, line 7 def initialize location @location = location end
Public Instance Methods
to_txt()
click to toggle source
# File lib/docx2txt.rb, line 11 def to_txt get_text get_xml end
Private Instance Methods
get_text(xml)
click to toggle source
# File lib/docx2txt.rb, line 23 def get_text xml lines = xml.children.map do |c| c.children.map do |i| i.children.map(&:text) end.flatten end.flatten lines.join("\n") end
get_xml()
click to toggle source
# File lib/docx2txt.rb, line 17 def get_xml Zip::File.new(@location).each do |entry| return Nokogiri.XML entry.get_input_stream.readlines.join if entry.name =~ /word.document.xml/ end end