Class: OoxmlParser::XlsxAlignment

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb

Overview

Character Alignment in XLSX

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(horizontal = :left, vertical = :bottom, wrap_text = false, parent: nil) ⇒ XlsxAlignment

Returns a new instance of XlsxAlignment.



6
7
8
9
10
11
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb', line 6

def initialize(horizontal = :left, vertical = :bottom, wrap_text = false, parent: nil)
  @horizontal = horizontal
  @vertical = vertical
  @wrap_text = wrap_text
  @parent = parent
end

Instance Attribute Details

#horizontalObject

Returns the value of attribute horizontal.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb', line 4

def horizontal
  @horizontal
end

#text_rotationObject

Returns the value of attribute text_rotation.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb', line 4

def text_rotation
  @text_rotation
end

#verticalObject

Returns the value of attribute vertical.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb', line 4

def vertical
  @vertical
end

#wrap_textObject

Returns the value of attribute wrap_text.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb', line 4

def wrap_text
  @wrap_text
end

Instance Method Details

#parse(node) ⇒ XlsxAlignment

Parse XlsxAlignment object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb', line 16

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