Class: Jobshop::Inspection::Report

Inherits:
ApplicationRecord show all
Defined in:
app/models/jobshop/inspection/report.rb

Instance Method Summary collapse

Instance Method Details

#asciiObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/jobshop/inspection/report.rb', line 20

def ascii
  require "terminal-table"
  table = Terminal::Table.new do |t|
    t.title = "Inspection Report"
    t << [ "Feature" ].concat(criteria.map(&:criterion).map(&:name))
    t << [ "Specification" ].concat(criteria.map(&:criterion).map(&:specification))
    tuples.each do |tuple|
      results = criteria.map do |criterion|
        tuple.results.find_by(criterion: criterion)
      end
      t << [ tuple.position ].concat(results.map(&:value))
    end
  end

  puts table
end