Class: CheckPlease::Printers::Long

Inherits:
Base
  • Object
show all
Defined in:
lib/check_please/printers/long.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, render

Constructor Details

This class inherits a constructor from CheckPlease::Printers::Base

Instance Method Details

#to_sObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/check_please/printers/long.rb', line 5

def to_s
  return "" if diffs.empty?

  out = build_string do |io|
    diffs.each do |diff|
      t = diff.type.to_sym
      ref, can = *[ diff.reference, diff.candidate ].map(&:inspect)
      diff_string = <<~EOF.strip
        #{diff.path} [#{diff.type}]
          reference: #{( t == :extra   ) ? "[no value]" : ref}
          candidate: #{( t == :missing ) ? "[no value]" : can}
      EOF

      io.puts diff_string
      io.puts
    end
  end

  out.strip
end