class Brightbox::SimpleTable
Remove most of the ascii art table output
Public Instance Methods
Source
# File lib/brightbox-cli/tables.rb, line 35 def enforce_field_constraints max_fields.each do |k, max| @field_lengths[k] = max if @field_lengths[k].to_i > max end # Never shrink the id field @field_lengths[:id] = IDENTIFIER_SIZE if @field_lengths[:id] end
Source
# File lib/brightbox-cli/tables.rb, line 23 def render_border "-" + @fields.map { |f| "-" * @field_lengths[f] }.join("--") + "-" end
Source
# File lib/brightbox-cli/tables.rb, line 27 def render_rows @rows.map do |row| row = " " + @fields.map do |f| format_cell(row[f], @field_lengths[f]) end.join(" ") end end
Source
# File lib/brightbox-cli/tables.rb, line 12 def render_table_header title_row = " " + @fields.map do |f| format_cell(@headers[f], @field_lengths[f]) end.join(" ") ["", title_row, render_border] end