Class: OoxmlParser::ParagraphSpacing

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_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

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

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:



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

def after
  @after
end

#beforeOoxmlSize

Returns value of before spacing.

Returns:



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

def before
  @before
end

#lineOoxmlSize

Returns value of line spacing.

Returns:



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

def line
  @line
end

#line_ruleSymbol

Returns value of line rule style.

Returns:

  • (Symbol)

    value of line rule style



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

def line_rule
  @line_rule
end

Instance Method Details

#parse(node) ⇒ ParagraphSpacing

Parse ParagraphSpacing

Parameters:

  • node (Nokogiri::XML:Node)

    with ParagraphSpacing

Returns:



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

def parse(node)
  sorted_attributes(node).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