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 a columnFence and a rowFence. Defaults to +.

    Declaration

    Swift

    public var cornerFence = "+"
  • The table’s header text. If set to nil, no header will be rendered. Defaults to nil.

    Declaration

    Swift

    public var header: String? = nil
  • Create a new TextTable from TextTableColumns.

    • parameters:
    • columns: An Array of TextTableColumns.
    • header: The table header. Defaults to nil.

    Declaration

    Swift

    public init(columns: [TextTableColumn], header: String? = nil)
  • Create a new TextTable from an TextTableRepresentables.

    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.