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

- (FachinfoWrapper) initialize(fachinfo)

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

- (Object) wrapper_class=(value) (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

- (Object) each_chapter(&block)



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

- (Object) first_chapter



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

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

- (Object) name



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

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

- (Boolean) need_new_page?(height, width, formats)

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