Sha256: c3c2e7c48bcbd74710e14fb823dfaed28c34739fa88951768254ee598b575b99
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# Creates a Section. # A section have a name and contains other elements. # Sections could be nested inside anothers class ReportBuilder::Section @@n=1 attr_reader :parent, :elements, :name def initialize(options=Hash.new, &block) if !options.has_key? :name @name="Section #{@@n}" @@n+=1 else @name=options[:name] end @parent = nil @elements = [] if block add(block) end end def parent=(sect) if sect.is_a? ReportBuilder::Section @parent=sect else raise ArgumentError("Parent should be a Section") end end def report_building_text(builder) builder.text(("="*builder.parse_level)+" "+name) builder.parse_cycle(self) end def report_building_html(g) htag="h#{g.parse_level+1}" anchor=g.toc_entry(name) g.html "<div class='section'><#{htag}>#{name}</#{htag}><a name='#{anchor}'></a>" g.parse_cycle(self) g.html "</div>" end def report_building_rtf(g) level=g.parse_level g.header(level, name) g.parse_cycle(self) end def report_building_pdf(g) level=g.parse_level g.header(level, name) g.parse_cycle(self) end def add(element) if element.is_a? ReportBuilder::Section element.parent=self end @elements.push(element) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reportbuilder-1.4.0 | lib/reportbuilder/section.rb |