Sha256: 999dcc9a3d1ef09490ef795dc14baee5246310078fef88f4583770194f056978

Contents?: true

Size: 1.56 KB

Versions: 15

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

15 entries across 15 versions & 1 rubygems

Version Path
ooxml_parser-0.24.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.23.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.22.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.21.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.20.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.19.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.18.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.18.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.17.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.16.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.15.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.14.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.14.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb
ooxml_parser-0.14.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb