class KXI::CLI::Table::Column
Represents a column of table
Public Class Methods
new(name)
click to toggle source
Instantiates the {KXI::CLI::Table::Column} class @param [string] name Name of column
# File lib/kxi/cli/table.rb, line 60 def initialize(name) @name = name @align = 0 @data = [] end
Public Instance Methods
align()
click to toggle source
Gets the length of the longest value @return [integer] Length of the longest value
# File lib/kxi/cli/table.rb, line 48 def align @align end
name()
click to toggle source
Gets the name of column @return [string] Name of column
# File lib/kxi/cli/table.rb, line 54 def name @name end
row(str)
click to toggle source
Adds a row to the column @param [string] str Value of row to add
# File lib/kxi/cli/table.rb, line 68 def row(str) @align = str.length if @align < str.length @data.push(str) end
write(row)
click to toggle source
Writes the value of a row at given index to stdout @param [integer] row Index of the row to write
# File lib/kxi/cli/table.rb, line 75 def write(row) str = @data[row] str = '' if str == nil print(str.ljust(@align)) end