Class: OoxmlParser::Indents

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb

Overview

Class for working with Indents data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(first_line_indent = OoxmlSize.new(0), left_indent = OoxmlSize.new(0), right_indent = OoxmlSize.new(0), hanging_indent = OoxmlSize.new(0), parent: nil) ⇒ Indents

Returns a new instance of Indents.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 8

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

Instance Attribute Details

#first_line_indentObject Also known as: first_line

Returns the value of attribute first_line_indent.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 6

def first_line_indent
  @first_line_indent
end

#hanging_indentObject Also known as: hanging

Returns the value of attribute hanging_indent.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 6

def hanging_indent
  @hanging_indent
end

#left_indentObject Also known as: left

Returns the value of attribute left_indent.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 6

def left_indent
  @left_indent
end

#right_indentObject Also known as: right

Returns the value of attribute right_indent.



6
7
8
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 6

def right_indent
  @right_indent
end

Instance Method Details

#parse(node) ⇒ Indents

Parse Indents

Parameters:

  • node (Nokogiri::XML:Element)

    with Indents

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 35

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

#to_sString

Convert to string

Returns:

  • (String)

    result of conversion



27
28
29
30
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/indents.rb', line 27

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