Sha256: 73993ceb5a508711764bbed4897ec3f506ba8b922609b6d1f0aa2f6f06326381

Contents?: true

Size: 957 Bytes

Versions: 3

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for working with ParagraphMargins
  class ParagraphMargins < TableMargins
    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

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ooxml_parser-0.6.0 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb
ooxml_parser-0.5.1 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb
ooxml_parser-0.5.0 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb