Class: Prawn::Table::CellBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/table/cell.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ CellBlock

Not sure if this class is something I want to expose in the public API.



231
232
233
234
235
236
# File 'lib/prawn/table/cell.rb', line 231

def initialize(document)
  @document = document
  @cells    = []
  @width    = 0
  @height   = 0
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



239
240
241
# File 'lib/prawn/table/cell.rb', line 239

def background_color
  @background_color
end

#border_colorObject

Returns the value of attribute border_color.



239
240
241
# File 'lib/prawn/table/cell.rb', line 239

def border_color
  @border_color
end

#cellsObject (readonly)

Returns the value of attribute cells.



238
239
240
# File 'lib/prawn/table/cell.rb', line 238

def cells
  @cells
end

#heightObject (readonly)

Returns the value of attribute height.



238
239
240
# File 'lib/prawn/table/cell.rb', line 238

def height
  @height
end

#text_colorObject

Returns the value of attribute text_color.



239
240
241
# File 'lib/prawn/table/cell.rb', line 239

def text_color
  @text_color
end

#widthObject (readonly)

Returns the value of attribute width.



238
239
240
# File 'lib/prawn/table/cell.rb', line 238

def width
  @width
end

Instance Method Details

#<<(cell) ⇒ Object



241
242
243
244
245
246
# File 'lib/prawn/table/cell.rb', line 241

def <<(cell)
  @cells << cell
  @height = cell.height if cell.height > @height 
  @width += cell.width
  self
end

#align=(align) ⇒ Object



274
275
276
# File 'lib/prawn/table/cell.rb', line 274

def align=(align) 
  @cells.each { |e| e.align = align } 
end

#border_styleObject



278
279
280
# File 'lib/prawn/table/cell.rb', line 278

def border_style
  @cells[0].border_style
end

#border_style=(s) ⇒ Object



270
271
272
# File 'lib/prawn/table/cell.rb', line 270

def border_style=(s)
  @cells.each { |e| e.border_style = s }
end

#border_widthObject



266
267
268
# File 'lib/prawn/table/cell.rb', line 266

def border_width
  @cells[0].border_width
end

#drawObject



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/prawn/table/cell.rb', line 248

def draw
  y = @document.y
  x = @document.bounds.left_side

  @cells.each do |e|
    e.point  = [x - @document.bounds.absolute_left, 
                y - @document.bounds.absolute_bottom]
    e.height = @height
    e.background_color ||= @background_color
    e.text_color ||= @text_color
    e.border_color ||= @border_color
    e.draw
    x += e.width
  end
  
  @document.y = y - @height
end