class AsciiParadise::AsciiTable::Separator

Public Instance Methods

render() click to toggle source
#

render

#
# File lib/ascii_paradise/asciitable/separator.rb, line 18
def render
  arr_x = (0...@table.number_of_columns).to_a.map { |i|
    n_characters = @table.column_width(i) + @table.cell_padding
    # ===================================================================== #
    # Do a horizontal spacer, via the '-' characters.
    # ===================================================================== #
    result = @table.style.border_x * n_characters
    if AsciiTable.use_colours?
      result = Colours.send(
        AsciiParadise::AsciiTable.use_which_colours?, result
      )
    end
    result
  }
  # ======================================================================= #
  # Next, we need to determine the border style. border_i means
  # '+' tokens.
  # ======================================================================= #
  border_i = @table.style.border_i
  # ======================================================================= #
  # Next we colour colourize this.
  # ======================================================================= #
  if AsciiTable.use_colours?
    border_i = Colours.send(
      AsciiParadise::AsciiTable.use_which_colours?, border_i
    )
  end
  result = border_i + arr_x.join(border_i) + border_i
  result
end