TextTable
public struct TextTable
Used to create a tabular representation of data.
-
The
String
used to separate columns in the table. Defaults to|
.Declaration
Swift
public var columnFence = "|"
-
The
String
used to separate rows in the table. Defaults to-
.Declaration
Swift
public var rowFence = "-"
-
The
String
used to mark the intersections of acolumnFence
and arowFence
. Defaults to+
.Declaration
Swift
public var cornerFence = "+"
-
The table’s header text. If set to
nil
, no header will be rendered. Defaults tonil
.Declaration
Swift
public var header: String? = nil
-
Create a new
TextTable
fromTextTableColumn
s.- parameters:
- columns: An
Array
ofTextTableColumn
s. - header: The table header. Defaults to
nil
.
Declaration
Swift
public init(columns: [TextTableColumn], header: String? = nil)
-
Create a new
TextTable
from anTextTableRepresentable
s.- parameters:
- objects: An
Array
ofTextTableRepresentable
s. - header: The table header. This will override the header specified by the
TextTableRepresentable
. Defaults tonil
.
Declaration
Swift
public init<T: TextTableRepresentable>(objects: [T], header: String? = nil)
-
Add a row to the table.
- parameters:
- values: The values contained in the new row.
Declaration
Swift
public mutating func addRow(values: [CustomStringConvertible])
-
Render the table to a
String
.Declaration
Swift
public func render() -> String
Return Value
The
String
representation of the table.