Class: OoxmlParser::ParagraphSpacing

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb

Overview

Class for parsing Paragraph Spacing in paragraph properties ‘w:spacing`

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, #initialize, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#afterOoxmlSize

Returns value of after spacing.

Returns:



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb', line 7

def after
  @after
end

#beforeOoxmlSize

Returns value of before spacing.

Returns:



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb', line 5

def before
  @before
end

#lineOoxmlSize

Returns value of line spacing.

Returns:



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb', line 9

def line
  @line
end

#line_ruleSymbol

Returns value of line rule style.

Returns:

  • (Symbol)

    value of line rule style



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb', line 11

def line_rule
  @line_rule
end

Instance Method Details

#parse(node) ⇒ Position

Parse Position

Parameters:

  • node (Nokogiri::XML:Node)

    with Position

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_spacing.rb', line 16

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'before'
      @before = OoxmlSize.new(value.value.to_f)
    when 'after'
      @after = OoxmlSize.new(value.value.to_f)
    when 'lineRule'
      @line_rule = value.value.sub('atLeast', 'at_least').to_sym
    when 'line'
      @line = if @line_rule == :auto
                OoxmlSize.new(value.value.to_f, :one_240th_cm)
              else
                OoxmlSize.new(value.value.to_f)
              end
    end
  end
  self
end