Sha256: 5ef3e2da45531e76b211d17c5cf1ba00cf44eb9b3d41349fbb577340bbd72128

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

module OoxmlParser
  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 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

    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

4 entries across 4 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb
ooxml_parser-0.4.0 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb
ooxml_parser-0.3.0 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb
ooxml_parser-0.2.0 lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb