Method: Tabulo::Table#horizontal_rule

Defined in:
lib/tabulo/table.rb

#horizontal_rule(position = :bottom) ⇒ String

Produce a horizontal dividing line suitable for printing at the top, bottom or middle of the table.

It may be that :top, :middle and :bottom all look the same. Whether this is the case depends on the characters used for the table border.

Examples:

Print a horizontal divider between each pair of rows, and again at the bottom:


table.each_with_index do |row, i|
  puts table.horizontal_rule(:middle) unless i == 0
  puts row
end
puts table.horizontal_rule(:bottom)

Parameters:

  • position (:top, :middle, :bottom, :title_top, :title_bottom) (defaults to: :bottom)

    Specifies the position for which the resulting horizontal dividing line is intended to be printed. This determines the border characters that are used to construct the line. The :title_top and :title_bottom options are used internally for adding borders above and below the table title text.

Returns:

  • (String)

    an "ASCII" graphical representation of a horizontal dividing line.



448
449
450
451
# File 'lib/tabulo/table.rb', line 448

def horizontal_rule(position = :bottom)
  column_widths = get_columns.map { |column| column.width + column.total_padding }
  @border_instance.horizontal_rule(column_widths, position)
end