Class: OoxmlParser::ParagraphMargins

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

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

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

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.



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

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

Instance Method Details

#parse(text_body_props_node) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb', line 23

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

#round(count_of_digits = 1) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb', line 15

def round(count_of_digits = 1)
  top = @top.round(count_of_digits)
  bottom = @bottom.round(count_of_digits)
  left = @left.round(count_of_digits)
  right = @right.round(count_of_digits)
  ParagraphMargins.new(top, bottom, left, right)
end