Class: CommandKit::Printing::Tables::RowBuilder Private
- Inherits:
-
Object
- Object
- CommandKit::Printing::Tables::RowBuilder
- Includes:
- Enumerable
- Defined in:
- lib/command_kit/printing/tables/row_builder.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.
Builds a table row and calculates it's dimensions.
Constant Summary collapse
- EMPTY_CELL =
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.
An empty cell.
CellBuilder.new
Instance Attribute Summary collapse
-
#cells ⇒ Array<CellBuilder>
readonly
private
The cells within the row.
-
#columns ⇒ Integer
readonly
private
The number of columns in the row.
-
#height ⇒ Integer
readonly
private
The height (in lines) for the row.
-
#width ⇒ Integer
readonly
private
The width (in characters) for the row.
Instance Method Summary collapse
-
#<<(value) ⇒ self
private
Appends a value to the row.
-
#[](column_index) ⇒ CellBuilder
private
Fetches a cell from the row.
-
#each {|cell| ... } ⇒ Enumerator
private
Enumerates over each cell in the row.
-
#initialize(cells = nil) ⇒ RowBuilder
constructor
private
Initializes the row.
Constructor Details
#initialize(cells = nil) ⇒ RowBuilder
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 row.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 43 def initialize(cells=nil) @cells = [] @height = 0 @width = 0 @columns = 0 if cells cells.each { |value| self << value } end end |
Instance Attribute Details
#cells ⇒ Array<CellBuilder> (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 cells within the row.
20 21 22 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 20 def cells @cells end |
#columns ⇒ 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 number of columns in the row.
35 36 37 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 35 def columns @columns end |
#height ⇒ 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 height (in lines) for the row.
25 26 27 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 25 def height @height end |
#width ⇒ 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 width (in characters) for the row.
30 31 32 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 30 def width @width end |
Instance Method Details
#<<(value) ⇒ self
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.
Appends a value to the row.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 67 def <<(value) new_cell = if value then CellBuilder.new(value) else EMPTY_CELL end @height = new_cell.height if new_cell.height > @height @width += new_cell.width @columns += 1 @cells << new_cell return self end |
#[](column_index) ⇒ CellBuilder
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.
Fetches a cell from the row.
90 91 92 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 90 def [](column_index) @cells.fetch(column_index,EMPTY_CELL) end |
#each {|cell| ... } ⇒ Enumerator
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.
Enumerates over each cell in the row.
106 107 108 |
# File 'lib/command_kit/printing/tables/row_builder.rb', line 106 def each(&block) @cells.each(&block) end |