Class: ODDB::FiPDF::FachinfoWrapper

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
ext/fipdf/src/fachinfo_wrapper.rb,
ext/fipdf/test/fachinfo_wrapper_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fachinfo) ⇒ FachinfoWrapper

Returns a new instance of FachinfoWrapper.



10
11
12
13
14
# File 'ext/fipdf/src/fachinfo_wrapper.rb', line 10

def initialize(fachinfo)
	@wrapper_class = ChapterWrapper
	@fachinfo = fachinfo
	super
end

Instance Attribute Details

#wrapper_class=(value) ⇒ Object (writeonly)

Sets the attribute wrapper_class

Parameters:

  • value

    the value to set the attribute wrapper_class to.



13
14
15
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 13

def wrapper_class=(value)
  @wrapper_class = value
end

Instance Method Details

#each_chapter(&block) ⇒ Object



15
16
17
18
19
# File 'ext/fipdf/src/fachinfo_wrapper.rb', line 15

def each_chapter(&block)
	@fachinfo.each_chapter { |chapter|
		block.call(@wrapper_class.new(chapter))
	}
end

#first_chapterObject



32
33
34
# File 'ext/fipdf/src/fachinfo_wrapper.rb', line 32

def first_chapter
	@wrapper_class.new(@fachinfo.first_chapter)
end

#nameObject



29
30
31
# File 'ext/fipdf/src/fachinfo_wrapper.rb', line 29

def name
	"<b>" + @fachinfo.name + "</b>"
end

#need_new_page?(height, width, formats) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
# File 'ext/fipdf/src/fachinfo_wrapper.rb', line 20

def need_new_page?(height, width, formats)
	fmt_dname = formats[:drug_name]
	fmt_cname = formats[:company_name]
	height_dname = fmt_dname.get_height(name, width) + fmt_dname.margin
	height_cname = fmt_cname.get_height(@fachinfo.company_name, width)
	height = height - (height_dname + height_cname)
	(height <= 0) \
		|| first_chapter.need_new_page?(height, width, formats)
end