require 'command_line_reporter' # Context module Contexto # Display class class Display include CommandLineReporter def initialize @header = '** Contexto Contextualizes **' puts "\n" header title: @header, width: 80, align: 'center', rule: true, color: 'green', bold: true end def create_display(title, headings, rows) @title = title @headings = headings @rows = rows create_new_table end def create_new_table if @title header title: @title, width: 50, align: 'left', color: 'red', bold: true end table(border: true) do row header: true do @headings.each do |h| column(h, headings_options) end end @rows.each do |r| row do r.each do |rr| column(rr, row_options) end end end end end def headings_options { align: 'center', width: col_width } end def row_options { align: 'center', width: col_width, color: 'green' } end def col_width @col_width ||= @rows.map(&:size).max + 6 end end end