Class: OoxmlParser::Columns

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb

Overview

Class for data of Columns

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(columns_count = 0) ⇒ Columns

Returns a new instance of Columns.



19
20
21
22
23
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 19

def initialize(columns_count = 0)
  @count = columns_count
  @column_array = []
  super(parent: nil)
end

Instance Attribute Details

#column_arrayArray<Column>

Returns list of colujmns.

Returns:

  • (Array<Column>)

    list of colujmns



13
14
15
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 13

def column_array
  @column_array
end

#countInteger

Returns count of columns.

Returns:

  • (Integer)

    count of columns



8
9
10
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 8

def count
  @count
end

#equal_widthTrue, False Also known as: equal_width?

Returns is columns are equal width.

Returns:

  • (True, False)

    is columns are equal width



10
11
12
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 10

def equal_width
  @equal_width
end

#separatorBoolean (readonly)

Returns Draw Line Between Columns.

Returns:

  • (Boolean)

    Draw Line Between Columns



15
16
17
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 15

def separator
  @separator
end

#spaceOoxmlSize

Returns space between columns.

Returns:



17
18
19
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 17

def space
  @space
end

Instance Method Details

#[](key) ⇒ Array, Column

Returns accessor.

Returns:

  • (Array, Column)

    accessor



26
27
28
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 26

def [](key)
  @column_array[key]
end

#parse(node) ⇒ Columns

Parse Columns data

Parameters:

  • node (Nokogiri::XML:Element)

    with Columns data

Returns:

  • (Columns)

    value of Columns data



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/columns.rb', line 33

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'num'
      @count = value.value.to_i
    when 'sep'
      @separator = boolean_attribute_value(value)
    when 'equalWidth'
      @equal_width = boolean_attribute_value(value)
    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