class ResumeTXTFormatter
TXTFormatter
class
Public Class Methods
new(report, color = false)
click to toggle source
Calls superclass method
ResumeArrayFormatter::new
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 9 def initialize(report, color = false) @color = color super(report) @data = {} end
Public Instance Methods
process()
click to toggle source
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 15 def process rainbow_state = Rainbow.enabled Rainbow.enabled = @color build_data process_config process_cases process_conn_errors process_results process_hof deinit Rainbow.enabled = rainbow_state end
Private Instance Methods
process_cases()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 43 def process_cases w "#{Rainbow('CASES').bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| st.add_row %w[CASE MEMBERS GRADE STATE] @data[:cases].each do |line| st.add_row [line[:id], line[:members], format(' %<grade>3d', { grade: line[:grade] }), line[:letter]] end end w "#{my_screen_table}\n\n" end
process_config()
click to toggle source
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 32 def process_config w "#{Rainbow('CONFIGURATION').bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| @data[:config].each do |key, value| st.add_row [key.to_s, trim(value)] end end w "#{my_screen_table}\n\n" end
process_conn_errors()
click to toggle source
rubocop:enable Metrics/MethodLength
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 58 def process_conn_errors my_screen_table = Terminal::Table.new do |st| st.add_row %w[CASE MEMBERS HOST ERROR] @data[:cases].each do |line| line[:conn_status].each_pair do |h, e| st.add_row [line[:id], line[:members], h, e] end end end return unless my_screen_table.rows.size > 1 w "#{Rainbow('CONN ERRORS').bg(:red)}\n#{my_screen_table}\n" end
process_hof()
click to toggle source
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 84 def process_hof return if @data[:hall_of_fame].size < 3 w "\n#{Rainbow('HALL OF FAME').bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| @data[:hall_of_fame].each do |line| mycolor = :green mycolor = :red if line[0] < 50 text1 = Rainbow(line[0]).color(mycolor) text2 = Rainbow(line[1]).color(mycolor) if line[0] == @data[:results][:grade] text1 = text1.bright text2 = text2.bright end st.add_row [text1, text2] end end w "#{my_screen_table}\n" end
process_results()
click to toggle source
# File lib/teuton/report/formatter/resume_txt_formatter.rb, line 72 def process_results w "\n#{Rainbow('RESULTS').bg(:blue)}\n" my_screen_table = Terminal::Table.new do |st| @data[:results].each do |key, value| st.add_row [key.to_s, value.to_s] end end w "#{my_screen_table}\n" end