Class: RubyDocx::Block
- Inherits:
-
InextensibleBlock
- Object
- InextensibleBlock
- RubyDocx::Block
- Defined in:
- lib/ruby_docx/elements/block.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#content ⇒ Object
Returns the value of attribute content.
-
#styles ⇒ Object
Returns the value of attribute styles.
Attributes inherited from InextensibleBlock
Instance Method Summary collapse
- #append(block) ⇒ Object
- #build ⇒ Object
-
#initialize(content = nil, styles = {}, children = []) ⇒ Block
constructor
A new instance of Block.
- #prepend(block) ⇒ Object
Methods inherited from InextensibleBlock
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
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/ruby_docx/elements/block.rb', line 3 def children @children end |
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/ruby_docx/elements/block.rb', line 3 def content @content end |
#styles ⇒ Object
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 |
#build ⇒ Object
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 |