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.21.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.20.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.19.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.18.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.18.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.17.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.16.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.15.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.14.2 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.14.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.14.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.13.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.12.2 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.12.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.12.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.11.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.10.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.9.1 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
ooxml_parser-0.9.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb