Class: Clin::Text::TableSeparatorRow
- Defined in:
- lib/clin/text/table.rb
Overview
Table row that is filled with the same character
Instance Attribute Summary collapse
-
#char ⇒ Object
Char used for separation.
Attributes inherited from TableRow
Instance Method Summary collapse
- #delimiter_at(index) ⇒ Object
-
#initialize(table, char = nil, col_delimiter: true) ⇒ TableSeparatorRow
constructor
A new instance of TableSeparatorRow.
- #to_s ⇒ Object
Methods inherited from TableRow
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
#char ⇒ Object
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_s ⇒ Object
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 |