Exception: PgVerify::Doctor::DoctorError

Inherits:
Core::Error
  • Object
show all
Defined in:
lib/pg-verify/doctor/doctor.rb

Instance Method Summary collapse

Methods inherited from Core::Error

#to_formatted

Constructor Details

#initialize(warnings) ⇒ DoctorError

Returns a new instance of DoctorError.



7
8
9
# File 'lib/pg-verify/doctor/doctor.rb', line 7

def initialize(warnings)
    @warnings = warnings
end

Instance Method Details

#formattedObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/pg-verify/doctor/doctor.rb', line 10

def formatted()
    is_are, s = @warnings.length == 1 ? ["is", ""] : ["are", "s"]
    header = "There #{is_are} #{@warnings.length} warning#{s} for your installation:"
    string = @warnings.each_with_index.map { |w, i|
        title = "#{i + 1}) #{w.title}".c_warn
        body  = w.text.indented(str: "   ")
        "#{title}\n#{body}"
    }.join("\n\n")
    return header, string
end