class Prawn::Table::Cell::AsciiDoc
Attributes
align[RW]
valign[RW]
Public Class Methods
new(pdf, opts = {})
click to toggle source
Calls superclass method
Object::new
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 10 def initialize pdf, opts = {} @font_options = {} super pdf, [], opts end
Public Instance Methods
draw_content()
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 59 def draw_content pdf = @pdf # NOTE draw_bounded_content automatically adds FPTolerance to width and height pdf.bounds.instance_variable_set :@width, spanned_content_width # NOTE we've already reserved the space, so just let the box stretch to the bottom of the page to avoid overflow pdf.bounds.instance_variable_set :@height, pdf.y if @valign != :top && (excess_y = spanned_content_height - natural_content_height) > 0 pdf.move_down(@valign == :center ? (excess_y.fdiv 2) : excess_y) end # TODO: apply horizontal alignment (right now must use alignment on content block) # QUESTION inherit table cell font properties? pdf.traverse content nil end
dry_run()
click to toggle source
NOTE: automatic image sizing only works if cell has fixed width
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 32 def dry_run cell = self max_height = nil height, = @pdf.dry_run do max_height = bounds.height # NOTE: we should be able to use cell.max_width, but returns 0 in some conditions (like when colspan > 1) indent cell.padding_left, bounds.width - cell.width + cell.padding_right do # HACK: force margin_top to be applied move_down 0.0001 # TODO: truncate margin bottom of last block traverse cell.content end end # FIXME: prawn-table doesn't support cell taller than a single page [max_height, height - 0.0001].min end
font=(val)
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 27 def font= val @font_options[:family] = val end
font_style=(val)
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 15 def font_style= val @font_options[:style] = val end
natural_content_height()
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 54 def natural_content_height # NOTE when natural_content_height is called, we already know max width @natural_content_height ||= dry_run end
natural_content_width()
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 49 def natural_content_width # QUESTION can we get a better estimate of the natural width? @natural_content_width ||= (@pdf.bounds.width - padding_left - padding_right) end
size=(val)
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 23 def size= val @font_options[:size] = val end
text_color=(val)
click to toggle source
# File lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb, line 19 def text_color= val @font_options[:color] = val end