Sha256: 7176f7170ece91daf4ed587f2b63979be42c35a16b3993863b95c4a7de1fcff6
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'docx' # Use case to abstract FORM from word document class Eco::API::UseCases::OozeSamples::OozeFromDocCase < Eco::API::UseCases::OozeSamples::OozeUpdateCase name "ooze-forms-case" type :other def main(session, options, usecase) raise "You need to inherit from this class and call super with a block" unless block_given? super(session, options, usecase) do yield end end private def with_column(num = 0) with_tables do |table, i| raise "Column num (#{num}) is to big. Table '#{i}' only has #{table.column_count} columns." if table.column_count < num table.columns[num].cells.each_with_index do |cell_row, j| txt = normalize_string(cell_row.text) yield(txt, i, j, table, cell_row) end end end def with_tables raise "There are no tables in the doc" unless table_count > 0 i = 0 doc.tables.each do |table| yield(table, i) if block_given? i += 1 end end def table_count doc.tables.count end def tables? table_count > 0 end def doc @doc ||= Docx::Document.open(input_file) end def input_file options.dig(:source, :file) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eco-helpers-2.0.33 | lib/eco/api/usecases/ooze_samples/ooze_from_doc_case.rb |