Class: CommandKit::Printing::Tables::Style Private
- Inherits:
-
Object
- Object
- CommandKit::Printing::Tables::Style
- Defined in:
- lib/command_kit/printing/tables/style.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Contains the table's style configuration.
Constant Summary collapse
- BORDER_STYLES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Built-in border styles.
{ ascii: BorderStyle.new( top_left_corner: '+', top_border: '-', top_joined_border: '+', top_right_corner: '+', left_border: '|', left_joined_border: '+', horizontal_separator: '-', vertical_separator: '|', inner_joined_border: '+', right_border: '|', right_joined_border: '+', bottom_border: '-', bottom_left_corner: '+', bottom_joined_border: '+', bottom_right_corner: '+' ), line: BorderStyle.new( top_left_corner: '┌', top_border: '─', top_joined_border: '┬', top_right_corner: '┐', left_border: '│', left_joined_border: '├', horizontal_separator: '─', vertical_separator: '│', inner_joined_border: '┼', right_border: '│', right_joined_border: '┤', bottom_border: '─', bottom_left_corner: '└', bottom_joined_border: '┴', bottom_right_corner: '┘' ), double_line: BorderStyle.new( top_left_corner: '╔', top_border: '═', top_joined_border: '╦', top_right_corner: '╗', left_border: '║', left_joined_border: '╠', horizontal_separator: '═', vertical_separator: '║', inner_joined_border: '╬', right_border: '║', right_joined_border: '╣', bottom_border: '═', bottom_left_corner: '╚', bottom_joined_border: '╩', bottom_right_corner: '╝' ) }
Instance Attribute Summary collapse
-
#border ⇒ BorderStyle
readonly
private
The border style.
-
#justify ⇒ :left, ...
readonly
private
The justification to use for cells.
-
#justify_header ⇒ :left, ...
readonly
private
The justification to use for header cells.
-
#padding ⇒ Integer
readonly
private
The padding to use for cells.
-
#separate_rows ⇒ Boolean
readonly
private
Specifies whether to separate rows with a border row.
Instance Method Summary collapse
-
#initialize(border: nil, padding: 1, justify: :left, justify_header: :center, separate_rows: false) ⇒ Style
constructor
private
Initializes the style.
-
#separate_rows? ⇒ Boolean
private
Determines if the rows should be separated.
Constructor Details
#initialize(border: nil, padding: 1, justify: :left, justify_header: :center, separate_rows: false) ⇒ Style
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the style.
The top-border character.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/command_kit/printing/tables/style.rb', line 160 def initialize(border: nil, padding: 1, justify: :left, justify_header: :center, separate_rows: false) @border = case border when Hash BorderStyle.new(**border) when Symbol BORDER_STYLES.fetch(border) do raise(ArgumentError,"unknown border style (#{border.inspect}) must be either #{BORDER_STYLES.keys.map(&:inspect).join(', ')}") end when nil then nil else raise(ArgumentError,"invalid border value (#{border.inspect}) must be either #{BORDER_STYLES.keys.map(&:inspect).join(', ')}, Hash, or nil") end @padding = padding @justify = justify @justify_header = justify_header @separate_rows = separate_rows end |
Instance Attribute Details
#border ⇒ BorderStyle (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The border style.
75 76 77 |
# File 'lib/command_kit/printing/tables/style.rb', line 75 def border @border end |
#justify ⇒ :left, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The justification to use for cells.
85 86 87 |
# File 'lib/command_kit/printing/tables/style.rb', line 85 def justify @justify end |
#justify_header ⇒ :left, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The justification to use for header cells.
90 91 92 |
# File 'lib/command_kit/printing/tables/style.rb', line 90 def justify_header @justify_header end |
#padding ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The padding to use for cells.
80 81 82 |
# File 'lib/command_kit/printing/tables/style.rb', line 80 def padding @padding end |
#separate_rows ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Specifies whether to separate rows with a border row.
95 96 97 |
# File 'lib/command_kit/printing/tables/style.rb', line 95 def separate_rows @separate_rows end |
Instance Method Details
#separate_rows? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines if the rows should be separated.
191 192 193 |
# File 'lib/command_kit/printing/tables/style.rb', line 191 def separate_rows? @separate_rows end |