Class: Prawn::Graphics::CellBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/graphics/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.



184
185
186
187
188
189
# File 'lib/prawn/graphics/cell.rb', line 184

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

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



192
193
194
# File 'lib/prawn/graphics/cell.rb', line 192

def background_color
  @background_color
end

#heightObject (readonly)

Returns the value of attribute height.



191
192
193
# File 'lib/prawn/graphics/cell.rb', line 191

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



191
192
193
# File 'lib/prawn/graphics/cell.rb', line 191

def width
  @width
end

Instance Method Details

#<<(cell) ⇒ Object



194
195
196
197
198
199
# File 'lib/prawn/graphics/cell.rb', line 194

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

#borderObject



217
218
219
# File 'lib/prawn/graphics/cell.rb', line 217

def border
  @cells[0].border
end

#border_styleObject



225
226
227
# File 'lib/prawn/graphics/cell.rb', line 225

def border_style
  @cells[0].border_style
end

#border_style=(s) ⇒ Object



221
222
223
# File 'lib/prawn/graphics/cell.rb', line 221

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

#drawObject



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/prawn/graphics/cell.rb', line 201

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.draw
    x += e.width
  end
  
  @document.y = y - @height
end