Class: OoxmlParser::PageMargins

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb

Overview

Class for parsing ‘pgMar` tags

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

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(params) ⇒ PageMargins

Returns a new instance of PageMargins.



6
7
8
9
10
11
12
13
14
15
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 6

def initialize(params)
  @top = params[:top]
  @bottom = params[:bottom]
  @left = params[:left]
  @right = params[:right]
  @header = params[:header]
  @footer = params[:footer]
  @gutter = params[:gutter]
  @parent = params[:parent]
end

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def bottom
  @bottom
end

Returns the value of attribute footer.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def footer
  @footer
end

#gutterObject

Returns the value of attribute gutter.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def gutter
  @gutter
end

#headerObject

Returns the value of attribute header.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def header
  @header
end

#leftObject

Returns the value of attribute left.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def left
  @left
end

#rightObject

Returns the value of attribute right.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def right
  @right
end

#topObject

Returns the value of attribute top.



4
5
6
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 4

def top
  @top
end

Instance Method Details

#parse(node) ⇒ PageMargins

Parse BordersProperties

Parameters:

  • node (Nokogiri::XML:Element)

    with PageMargins

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb', line 20

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'top'
      @top = OoxmlSize.new(value.value.to_f)
    when 'left'
      @left = OoxmlSize.new(value.value.to_f)
    when 'right'
      @right = OoxmlSize.new(value.value.to_f)
    when 'bottom'
      @bottom = OoxmlSize.new(value.value.to_f)
    when 'header'
      @header = OoxmlSize.new(value.value.to_f)
    when 'footer'
      @footer = OoxmlSize.new(value.value.to_f)
    when 'gutter'
      @gutter = OoxmlSize.new(value.value.to_f)
    end
  end
  self
end