Class: ODFWriter::Section
- Inherits:
-
Object
- Object
- ODFWriter::Section
- Includes:
- Nested
- Defined in:
- lib/odf_writer/section.rb
Overview
Section: poulate and grow sections
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#name ⇒ Object
Returns the value of attribute name.
-
#proc ⇒ Object
Returns the value of attribute proc.
Instance Method Summary collapse
-
#get_section_content(doc) ⇒ Object
get_section_content.
-
#initialize(options) ⇒ Section
constructor
initialize.
-
#replace!(doc, manifest, file, row = nil) ⇒ Object
replace!.
Methods included from Nested
#add_bookmark, #add_field, #add_image, #add_section, #add_table, #add_text, #items, #populate
Constructor Details
#initialize(options) ⇒ Section
initialize
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/odf_writer/section.rb', line 39 def initialize() @name = [:name] @field = [:field] @key = @field || @name @collection = [:collection] @proc = [:proc] @fields = [] @bookmarks = [] @images = [] @texts = [] @tables = [] @sections = [] end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
32 33 34 |
# File 'lib/odf_writer/section.rb', line 32 def collection @collection end |
#name ⇒ Object
Returns the value of attribute name.
32 33 34 |
# File 'lib/odf_writer/section.rb', line 32 def name @name end |
#proc ⇒ Object
Returns the value of attribute proc.
32 33 34 |
# File 'lib/odf_writer/section.rb', line 32 def proc @proc end |
Instance Method Details
#get_section_content(doc) ⇒ Object
get_section_content
59 60 61 62 |
# File 'lib/odf_writer/section.rb', line 59 def get_section_content( doc ) return unless @section_node = find_section_node(doc) @section_node.content end |
#replace!(doc, manifest, file, row = nil) ⇒ Object
replace!
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/odf_writer/section.rb', line 69 def replace!(doc, manifest, file, row = nil) return unless @section_node = find_section_node(doc) @collection = items(row, @key, @proc) if row @collection.each do |item| new_section = get_section_node # # experimental: new node must be added to doc prior to replace! # else new_section does not have a name space # @section_node.before(new_section) @tables.each { |t| t.replace!(new_section, manifest, file, item) } @sections.each { |s| s.replace!(new_section, manifest, file, item) } @texts.each { |t| t.replace!(new_section, item) } @fields.each { |f| f.replace!(new_section, item) } @bookmarks.each { |b| b.replace!(new_section, item) } @images.each { |b| b.replace!(new_section, manifest, file, item) } end Image.unique_image_names( doc) if @images.present? @section_node.remove end |