Sha256: 7a092bd6bb70c7dd940c5eac8946abd70ee7d67a2a81d872af1f5ddf6fe1e4e0
Contents?: true
Size: 1.13 KB
Versions: 8
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require_relative 'matrix/matrix_row' module OoxmlParser # Class for 'm' data class Matrix < OOXMLDocumentObject attr_accessor :rows def initialize(parent: nil) @rows = [] super end # Parse Matrix object # @param node [Nokogiri::XML:Element] node to parse # @return [Matrix] result of parsing def parse(node) columns_count = 1 j = 0 node.xpath('m:mPr').each do |m_pr| m_pr.xpath('m:mcs').each do |mcs| mcs.xpath('m:mc').each do |mc| mc.xpath('m:mcPr').each do |mc_pr| mc_pr.xpath('m:count').each do |count| count_object = ValuedChild.new(:integer, parent: self).parse(count) columns_count = count_object.value end end end end end node.xpath('m:mr').each do |mr| i = 0 @rows << MatrixRow.new(columns_count, parent: self) mr.xpath('m:e').each do |e| @rows[j].columns[i] = DocxFormula.new(parent: self).parse(e) i += 1 end j += 1 end self end end end
Version data entries
8 entries across 8 versions & 1 rubygems