Sha256: e28cf6c5d3be438c3b474008be21b29e703d047028a2eb754c1cb93ac8440332

Contents?: true

Size: 1 KB

Versions: 40

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Character Alignment in XLSX
  class XlsxAlignment < OOXMLDocumentObject
    attr_accessor :horizontal, :vertical, :wrap_text, :text_rotation

    def initialize(params = {})
      @horizontal = params.fetch(:horizontal, :left)
      @vertical = params.fetch(:vertical, :bottom)
      @wrap_text = params.fetch(:wrap_text, false)
      super(parent: params[:parent])
    end

    # Parse XlsxAlignment object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [XlsxAlignment] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'horizontal'
          @horizontal = value.value.to_sym
          @wrap_text = true if @horizontal == :justify
        when 'vertical'
          @vertical = value.value.to_sym
        when 'wrapText'
          @wrap_text = value.value.to_s == '1'
        when 'textRotation'
          @text_rotation = value.value.to_i
        end
      end
      self
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.36.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.36.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.35.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.34.2 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.34.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.34.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.33.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.32.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.31.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.30.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.29.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.28.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.27.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.26.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.25.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.24.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.23.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.22.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb