Class: AsciiParadise::AsciiTable::Separator

Inherits:
Row
  • Object
show all
Defined in:
lib/ascii_paradise/asciitable/separator.rb

Instance Method Summary collapse

Methods inherited from Row

#[], #add_cell, #cells?, #height, #initialize, #reset, #table?

Constructor Details

This class inherits a constructor from AsciiParadise::AsciiTable::Row

Instance Method Details

#renderObject

#

render

#


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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