Class: DocxGenerator::Word::Spacing

Inherits:
Element
  • Object
show all
Defined in:
lib/docx_generator/word/formatting.rb

Overview

Represent the ‘w:spacing` element from Office Open XML specification. This class should not be used directly by the users of the library.

Instance Method Summary collapse

Methods inherited from Element

#add, #generate

Constructor Details

#initialize(arguments = {}) ⇒ Spacing

Create a new ‘w:spacing` element.

Parameters:

  • arguments (Hash) (defaults to: {})

    The different options for the spacing. They can be found in the specification.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/docx_generator/word/formatting.rb', line 64

def initialize(arguments = {})
  final_arguments = {}
  arguments.each do |name, value|
    if name.to_s == "after" || name.to_s == "before"
      final_arguments["w:" + name.to_s] = (value * 20).round
    else
      final_arguments["w:" + name.to_s] = (value * 20 * 12).round
      final_arguments["w:lineRule"] = "auto"
    end
  end
  super("w:spacing", final_arguments)
end