Class: OoxmlParser::ParagraphMargins

Inherits:
TableMargins show all
Defined in:
lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb

Overview

Class for working with ParagraphMargins

Instance Attribute Summary

Attributes inherited from TableMargins

#bottom, #is_default, #left, #right, #top

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from TableMargins

#==, #to_s

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(top = OoxmlSize.new(0), bottom = OoxmlSize.new(0), left = OoxmlSize.new(0), right = OoxmlSize.new(0), parent: nil) ⇒ ParagraphMargins

Returns a new instance of ParagraphMargins.



6
7
8
9
10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb', line 6

def initialize(top = OoxmlSize.new(0),
               bottom = OoxmlSize.new(0),
               left = OoxmlSize.new(0),
               right = OoxmlSize.new(0),
               parent: nil)
  super(true, top, bottom, left, right, parent: parent)
end

Instance Method Details

#parse(text_body_props_node) ⇒ ParagraphMargins

Parse ParagraphMargins object

Parameters:

  • text_body_props_node (Nokogiri::XML:Element)

    node to parse

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb', line 17

def parse(text_body_props_node)
  text_body_props_node.attributes.each do |key, value|
    case key
    when 'bIns', 'marB'
      @bottom = OoxmlSize.new(value.value.to_f, :emu)
    when 'tIns', 'marT'
      @top = OoxmlSize.new(value.value.to_f, :emu)
    when 'lIns', 'marL'
      @left = OoxmlSize.new(value.value.to_f, :emu)
    when 'rIns', 'marR'
      @right = OoxmlSize.new(value.value.to_f, :emu)
    end
  end
  self
end