Class: Docxtor2::Package::Document::Paragraph

Inherits:
Element show all
Defined in:
lib/docxtor2/package/document/paragraph.rb

Direct Known Subclasses

Heading

Instance Method Summary collapse

Methods included from ObjectUtils

#find_argument

Methods included from BlockEvaluator

#evaluate

Methods inherited from ElementList

map

Constructor Details

#initialize(*args, &block) ⇒ Paragraph

Returns a new instance of Paragraph.



3
4
5
6
7
8
9
10
# File 'lib/docxtor2/package/document/paragraph.rb', line 3

def initialize(*args, &block)
  super(*args, &block)
  Known::Mappings::PARAGRAPH_COMPLEX.each do |name, element|
    @params[name] ||= {}
  end
  @params[:space] ||= 'default'
  @contents = create_contents(args)
end

Instance Method Details

#line_breakObject Also known as: br



31
32
33
# File 'lib/docxtor2/package/document/paragraph.rb', line 31

def line_break
  @contents << :br
end

#preserve_whitespaceObject



35
36
37
# File 'lib/docxtor2/package/document/paragraph.rb', line 35

def preserve_whitespace
  @params[:space] = 'preserve'
end

#render(xml) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/docxtor2/package/document/paragraph.rb', line 12

def render(xml)
  super(xml)
  write_element(:p) do
    write_element(:r) do
      write_contents
    end
  end
end

#write(text) ⇒ Object Also known as: w



39
40
41
# File 'lib/docxtor2/package/document/paragraph.rb', line 39

def write(text)
  @contents << text
end