Sha256: b07fb378de88fc1a2d6cb5e939a2bd76878c90484db7339ec2d76807f4856745

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require_relative 'columns/column'
module OoxmlParser
  # Class for data of Columns
  class Columns < OOXMLDocumentObject
    # @return [Integer] count of columns
    attr_accessor :count
    # @return [True, False] is columns are equal width
    attr_accessor :equal_width
    alias equal_width? equal_width
    # @return [Array<Column>] list of colujmns
    attr_accessor :column_array
    # @return [Boolean] Draw Line Between Columns
    attr_reader :separator
    # @return [OoxmlSize] space between columns
    attr_accessor :space

    def initialize(columns_count = 0)
      @count = columns_count
      @column_array = []
    end

    # @return [Array, Column] accessor
    def [](key)
      @column_array[key]
    end

    # Parse Columns data
    # @param [Nokogiri::XML:Element] node with Columns data
    # @return [Columns] value of Columns data
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'num'
          @count = value.value.to_i
        when 'sep'
          @separator = option_enabled?(node, 'sep')
        when 'equalWidth'
          @equal_width = option_enabled?(node, 'equalWidth')
        when 'space'
          @space = OoxmlSize.new(value.value.to_f)
        end
      end

      node.xpath('*').each do |column_node|
        case column_node.name
        when 'col'
          @column_array << Column.new(parent: self).parse(column_node)
        end
      end
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ooxml_parser-0.8.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb
ooxml_parser-0.8.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb