Class: OoxmlParser::NumberingProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb

Overview

Class for parsing ‘numPr` tags

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(ilvl = 0, parent: nil) ⇒ NumberingProperties

Returns a new instance of NumberingProperties.



12
13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 12

def initialize(ilvl = 0, parent: nil)
  @default_i_level = ilvl
  super(parent: parent)
end

Instance Attribute Details

#fontObject

Returns the value of attribute font.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 6

def font
  @font
end

#i_levelValuedChild (readonly)

Returns i level.

Returns:



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 8

def i_level
  @i_level
end

#imageObject

Returns the value of attribute image.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 6

def image
  @image
end

#num_idValuedChild (readonly)

Returns numbering id.

Returns:



10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 10

def num_id
  @num_id
end

#sizeObject

Returns the value of attribute size.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 6

def size
  @size
end

#start_atObject

Returns the value of attribute start_at.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 6

def start_at
  @start_at
end

#symbolObject

Returns the value of attribute symbol.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 6

def symbol
  @symbol
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 6

def type
  @type
end

Instance Method Details

#abstruct_numberingAbstractNumbering

Returns AbstractNumbering of current properties.

Returns:



18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 18

def abstruct_numbering
  root_object.numbering.properties_by_num_id(numbering_properties)
end

#ilvlInteger

Returns i-level value.

Returns:

  • (Integer)

    i-level value



43
44
45
46
47
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 43

def ilvl
  return @default_i_level unless @i_level

  @i_level.value
end

#numbering_level_currentAbstractNumbering

Returns level list of current numbering.

Returns:



50
51
52
53
54
55
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 50

def numbering_level_current
  abstruct_numbering.level_list.each do |current_ilvl|
    return current_ilvl if current_ilvl.ilvl == ilvl
  end
  nil
end

#numbering_propertiesInteger

Returns numbering properties.

Returns:

  • (Integer)

    numbering properties



38
39
40
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 38

def numbering_properties
  @num_id.value
end

#parse(node) ⇒ NumberingProperties

Parse NumberingProperties

Parameters:

  • node (Nokogiri::XML:Node)

    with NumberingProperties

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb', line 25

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'ilvl'
      @i_level = ValuedChild.new(:integer, parent: self).parse(node_child)
    when 'numId'
      @num_id = ValuedChild.new(:integer, parent: self).parse(node_child)
    end
  end
  self
end