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.



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

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

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



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

def background_color
  @background_color
end

#border_colorObject

Returns the value of attribute border_color.



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

def border_color
  @border_color
end

#cellsObject (readonly)

Returns the value of attribute cells.



236
237
238
# File 'lib/prawn/table/cell.rb', line 236

def cells
  @cells
end

#heightObject (readonly)

Returns the value of attribute height.



236
237
238
# File 'lib/prawn/table/cell.rb', line 236

def height
  @height
end

#text_colorObject

Returns the value of attribute text_color.



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

def text_color
  @text_color
end

#widthObject (readonly)

Returns the value of attribute width.



236
237
238
# File 'lib/prawn/table/cell.rb', line 236

def width
  @width
end

Instance Method Details

#<<(cell) ⇒ Object



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

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

#align=(align) ⇒ Object



272
273
274
# File 'lib/prawn/table/cell.rb', line 272

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

#border_styleObject



276
277
278
# File 'lib/prawn/table/cell.rb', line 276

def border_style
  @cells[0].border_style
end

#border_style=(s) ⇒ Object



268
269
270
# File 'lib/prawn/table/cell.rb', line 268

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

#border_widthObject



264
265
266
# File 'lib/prawn/table/cell.rb', line 264

def border_width
  @cells[0].border_width
end

#drawObject



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

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

  @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