Class: ODDB::FiPDF::ChapterWrapper
- Defined in:
- ext/fipdf/src/chapter_wrapper.rb,
ext/fipdf/test/chapter_wrapper_test.rb
Instance Attribute Summary collapse
-
#wrapper_class ⇒ Object
writeonly
Sets the attribute wrapper_class.
Instance Method Summary collapse
- #each_section(&block) ⇒ Object
- #first_section ⇒ Object
-
#initialize(chapter) ⇒ ChapterWrapper
constructor
A new instance of ChapterWrapper.
- #need_new_page?(height, width, formats) ⇒ Boolean
Constructor Details
#initialize(chapter) ⇒ ChapterWrapper
Returns a new instance of ChapterWrapper.
10 11 12 13 14 |
# File 'ext/fipdf/src/chapter_wrapper.rb', line 10 def initialize(chapter) @wrapper_class = SectionWrapper @chapter = chapter super end |
Instance Attribute Details
#wrapper_class=(value) ⇒ Object (writeonly)
Sets the attribute wrapper_class
12 13 14 |
# File 'ext/fipdf/test/chapter_wrapper_test.rb', line 12 def wrapper_class=(value) @wrapper_class = value end |
Instance Method Details
#each_section(&block) ⇒ Object
15 16 17 18 19 |
# File 'ext/fipdf/src/chapter_wrapper.rb', line 15 def each_section(&block) @chapter.sections.each { |section| block.call(@wrapper_class.new(section)) } end |
#first_section ⇒ Object
33 34 35 36 37 |
# File 'ext/fipdf/src/chapter_wrapper.rb', line 33 def first_section unless(@chapter.sections.empty?) @wrapper_class.new(@chapter.sections.first) end end |
#need_new_page?(height, width, formats) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'ext/fipdf/src/chapter_wrapper.rb', line 20 def need_new_page?(height, width, formats) fmt_heading = formats[:chapter] #puts "height original #{height}" #puts @chapter.heading height_heading = fmt_heading.get_height(@chapter.heading, width) #puts height_heading height = height - height_heading #puts "height minus heading height #{height}" first = first_section (height <= 0) \ || (!first.nil? \ && first.need_new_page?(height, width, formats)) end |