class OoxmlParser::ParagraphMargins

Class for working with ParagraphMargins

Public Class Methods

new(top = OoxmlSize.new(0), bottom = OoxmlSize.new(0), left = OoxmlSize.new(0), right = OoxmlSize.new(0), parent: nil) click to toggle source
Calls superclass method
# 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

Public Instance Methods

parse(text_body_props_node) click to toggle source

Parse ParagraphMargins object @param text_body_props_node [Nokogiri::XML:Element] node to parse @return [ParagraphMargins] result of parsing

# 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