Class: TablePal::Column
- Inherits:
-
Object
- Object
- TablePal::Column
- Defined in:
- lib/column.rb
Instance Attribute Summary collapse
-
#colour ⇒ Object
readonly
Returns the value of attribute colour.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#justification ⇒ Object
readonly
Returns the value of attribute justification.
-
#left_border ⇒ Object
readonly
Returns the value of attribute left_border.
-
#left_padding ⇒ Object
readonly
Returns the value of attribute left_padding.
-
#right_border ⇒ Object
readonly
Returns the value of attribute right_border.
-
#right_padding ⇒ Object
readonly
Returns the value of attribute right_padding.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(table:, formatter: nil, left_padding: ' ', right_padding: ' ', left_border: '', right_border: '|', justification: :left, colour: nil) ⇒ Column
constructor
A new instance of Column.
- #left_padding_char(char) ⇒ Object
- #right_padding_char(char) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(table:, formatter: nil, left_padding: ' ', right_padding: ' ', left_border: '', right_border: '|', justification: :left, colour: nil) ⇒ Column
Returns a new instance of Column.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/column.rb', line 6 def initialize(table:, formatter: nil, left_padding: ' ', right_padding: ' ', left_border: '', right_border: '|', justification: :left, colour: nil) @table = table @formatter = formatter @left_padding = left_padding @right_padding = right_padding @left_border = left_border @right_border = right_border @justification = justification @colour = colour end |
Instance Attribute Details
#colour ⇒ Object (readonly)
Returns the value of attribute colour.
4 5 6 |
# File 'lib/column.rb', line 4 def colour @colour end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
4 5 6 |
# File 'lib/column.rb', line 4 def formatter @formatter end |
#justification ⇒ Object (readonly)
Returns the value of attribute justification.
4 5 6 |
# File 'lib/column.rb', line 4 def justification @justification end |
#left_border ⇒ Object (readonly)
Returns the value of attribute left_border.
4 5 6 |
# File 'lib/column.rb', line 4 def left_border @left_border end |
#left_padding ⇒ Object (readonly)
Returns the value of attribute left_padding.
4 5 6 |
# File 'lib/column.rb', line 4 def left_padding @left_padding end |
#right_border ⇒ Object (readonly)
Returns the value of attribute right_border.
4 5 6 |
# File 'lib/column.rb', line 4 def right_border @right_border end |
#right_padding ⇒ Object (readonly)
Returns the value of attribute right_padding.
4 5 6 |
# File 'lib/column.rb', line 4 def right_padding @right_padding end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
4 5 6 |
# File 'lib/column.rb', line 4 def table @table end |
Instance Method Details
#left_padding_char(char) ⇒ Object
21 22 23 |
# File 'lib/column.rb', line 21 def left_padding_char(char) char * left_padding.length end |
#right_padding_char(char) ⇒ Object
25 26 27 |
# File 'lib/column.rb', line 25 def right_padding_char(char) char * right_padding.length end |
#width ⇒ Object
17 18 19 |
# File 'lib/column.rb', line 17 def width @width ||= table.select_cells(column: self).max_by(&:width).width end |