Sha256: 2445a590d8a77ed4ce882680e1a9f623ea507c329125b3dd77c04dcaa454302c

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for working with Indents data
  class Indents < OOXMLDocumentObject
    attr_accessor :first_line_indent, :left_indent, :right_indent, :hanging_indent

    def initialize(first_line_indent = OoxmlSize.new(0),
                   left_indent = OoxmlSize.new(0),
                   right_indent = OoxmlSize.new(0),
                   hanging_indent = OoxmlSize.new(0),
                   parent: nil)
      @first_line_indent = first_line_indent
      @left_indent = left_indent
      @right_indent = right_indent
      @hanging_indent = hanging_indent
      @parent = parent
    end

    alias first_line first_line_indent
    alias left left_indent
    alias right right_indent
    alias hanging hanging_indent

    def to_s
      "first line indent: #{@first_line_indent}, left indent: #{@left_indent},
     right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
    end

    # Parse Indents
    # @param [Nokogiri::XML:Element] node with Indents
    # @return [Indents] value of Indents
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'firstLine'
          @first_line_indent = OoxmlSize.new(value.value.to_f)
        when 'left'
          @left_indent = OoxmlSize.new(value.value.to_f)
        when 'right'
          @right_indent = OoxmlSize.new(value.value.to_f)
        when 'hanging'
          @hanging_indent = OoxmlSize.new(value.value.to_f)
        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/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.5.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.5.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb