Class: RubyDocx::Block

Inherits:
InextensibleBlock show all
Defined in:
lib/ruby_docx/elements/block.rb

Direct Known Subclasses

Hyperlink, Paragraph, Row, Table, TableColumn, TableRow

Instance Attribute Summary collapse

Attributes inherited from InextensibleBlock

#document

Instance Method Summary collapse

Methods inherited from InextensibleBlock

#add_styles, create

Constructor Details

#initialize(content = nil, styles = {}, children = []) ⇒ Block

Returns a new instance of Block.



5
6
7
8
9
10
11
# File 'lib/ruby_docx/elements/block.rb', line 5

def initialize(content = nil, styles = {}, children = [])
  @content = content
  @children = children
  @styles = styles

  @template = 'block.xml'
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



3
4
5
# File 'lib/ruby_docx/elements/block.rb', line 3

def children
  @children
end

#contentObject

Returns the value of attribute content.



3
4
5
# File 'lib/ruby_docx/elements/block.rb', line 3

def content
  @content
end

#stylesObject

Returns the value of attribute styles.



3
4
5
# File 'lib/ruby_docx/elements/block.rb', line 3

def styles
  @styles
end

Instance Method Details

#append(block) ⇒ Object



13
14
15
# File 'lib/ruby_docx/elements/block.rb', line 13

def append(block)
  @children << block
end

#buildObject



21
22
23
24
25
26
# File 'lib/ruby_docx/elements/block.rb', line 21

def build
  node = super
  apply_styles(node)
  @children.each { |child| node.add_child child.build }
  node
end

#prepend(block) ⇒ Object



17
18
19
# File 'lib/ruby_docx/elements/block.rb', line 17

def prepend(block)
  @children.unshift block
end