Sha256: 3af230f7f41bd9168e96519df7370d86a97d4f56a093bd1180f555a2571aa499

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 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
      super(parent: parent)
    end

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

    # Convert to string
    # @return [String] result of conversion
    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

17 entries across 17 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.37.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.36.1 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.36.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.35.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.34.2 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.34.1 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.34.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.33.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.32.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.31.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.30.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.29.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.28.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.27.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.26.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.25.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb