Class: OoxmlParser::PageMargins

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/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

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(params) ⇒ PageMargins

Returns a new instance of PageMargins.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 8

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]
  super(parent: nil)
end

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def bottom
  @bottom
end

Returns the value of attribute footer.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def footer
  @footer
end

#gutterObject

Returns the value of attribute gutter.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def gutter
  @gutter
end

#headerObject

Returns the value of attribute header.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def header
  @header
end

#leftObject

Returns the value of attribute left.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def left
  @left
end

#rightObject

Returns the value of attribute right.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def right
  @right
end

#topObject

Returns the value of attribute top.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_margins.rb', line 6

def top
  @top
end

Instance Method Details

#parse(node, unit = :dxa) ⇒ PageMargins

Parse BordersProperties

Parameters:

  • node (Nokogiri::XML:Element)

    with PageMargins

Returns:



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

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