Class: PDFGen::SmartTable::RowsContainer

Inherits:
Div show all
Defined in:
lib/smart_table.rb

Instance Attribute Summary

Attributes inherited from Div

#count_rendered_region, #horizontal_align, #horizontal_interval, #optional_border

Attributes inherited from BaseRegion

#parent

Attributes included from BaseAttributes

#background_color, #border_bottom, #border_color, #border_left, #border_right, #border_style, #border_top, #border_width, #height, #is_breakable, #pad_bottom, #pad_left, #pad_right, #pad_top, #page_pad_top, #width

Instance Method Summary collapse

Methods inherited from Div

#add_border, #add_border_bottom, #add_border_sides, #add_border_top, #add_optional_border, #calculate_minimal_height, #render, #render_regions, #reset_count_rendered_regions

Methods included from Composite

#[], #add_region, #apply_values, #elements, #page_pad_top=, #regions, #render, #render_regions

Methods included from CaptionContainer

#caption

Methods included from PDFGen::SpanContainer

#span

Methods included from DivContainer

#div

Methods included from ImageContainer

#image

Methods included from TableContainer

#table

Methods inherited from BaseRegion

#check_fit_in_height, #document, #minimal_height, #render, #set_properties, #value

Methods included from BaseAttributes

#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init

Methods included from BaseAttributes::ClassMethods

#common_setter

Constructor Details

#initialize(parent) ⇒ RowsContainer

Returns a new instance of RowsContainer.



15
16
17
18
# File 'lib/smart_table.rb', line 15

def initialize(parent)
  super
  @cells = []
end

Instance Method Details

#cell(region = nil, style = nil, &initialization_block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/smart_table.rb', line 24

def cell(region=nil,style=nil,&initialization_block)
  if initialization_block
    cell = PDFGen.const_get(region.to_s.capitalize).new(self)
    cell.border_left = true
    cell.set_properties style unless style.nil?
    cell.instance_eval(&initialization_block)
    @cells << cell
  else
    caption = Caption.new(parent)
    caption.text = region
    caption.border_left = true
    caption.set_properties style unless style.nil?
    @cells << caption
  end
end

#dsObject



20
21
22
# File 'lib/smart_table.rb', line 20

def ds
  parent.data_source
end

#rowObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/smart_table.rb', line 40

def row
  span = Span.new(self.document)
  span.width = self.width
  span.border = true
  yield if block_given?
  @cells.each do |cell|
    if cell.width.zero? || cell.width == self.width
      cell.width = span.width / @cells.size
    end
    span.add_region(cell)
  end

  @cells.clear
  self.add_region(span)
end