Class: Clin::Text::TableSeparatorRow

Inherits:
TableRow
  • Object
show all
Defined in:
lib/clin/text/table.rb

Overview

Table row that is filled with the same character

Instance Attribute Summary collapse

Attributes inherited from TableRow

#cells

Instance Method Summary collapse

Methods inherited from TableRow

#border, #each

Constructor Details

#initialize(table, char = nil, col_delimiter: true) ⇒ TableSeparatorRow

Returns a new instance of TableSeparatorRow.



203
204
205
206
207
# File 'lib/clin/text/table.rb', line 203

def initialize(table, char = nil, col_delimiter: true)
  super(table, [])
  @char = char || @table.row_delim
  @include_column_delimiter = col_delimiter
end

Instance Attribute Details

#charObject

Char used for separation.



201
202
203
# File 'lib/clin/text/table.rb', line 201

def char
  @char
end

Instance Method Details

#delimiter_at(index) ⇒ Object



209
210
211
212
# File 'lib/clin/text/table.rb', line 209

def delimiter_at(index)
  col_delim = super(index)
  @include_column_delimiter ? col_delim : (@char * col_delim.size)
end

#to_sObject



214
215
216
217
218
219
220
221
# File 'lib/clin/text/table.rb', line 214

def to_s
  out = ''
  each_with_index do |_, i|
    out << @char * @table.column_length[i]
    out << delimiter_at(i)
  end
  border(out, @char)
end