Class: Chef::Formatters::ErrorDescription
- Defined in:
- lib/chef/formatters/error_descriptor.rb
Overview
Formatters::ErrorDescription
Class for displaying errors on STDOUT.
Instance Attribute Summary collapse
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Instance Method Summary collapse
- #display(out) ⇒ Object
- #for_json ⇒ Object
-
#initialize(title) ⇒ ErrorDescription
constructor
A new instance of ErrorDescription.
- #section(heading, text) ⇒ Object
Constructor Details
#initialize(title) ⇒ ErrorDescription
Returns a new instance of ErrorDescription.
28 29 30 31 |
# File 'lib/chef/formatters/error_descriptor.rb', line 28 def initialize(title) @title = title @sections = [] end |
Instance Attribute Details
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
26 27 28 |
# File 'lib/chef/formatters/error_descriptor.rb', line 26 def sections @sections end |
Instance Method Details
#display(out) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/chef/formatters/error_descriptor.rb', line 37 def display(out) out.puts "=" * 80 out.puts @title, :red out.puts "=" * 80 out.puts "\n" sections.each do |section| display_section(section, out) end end |
#for_json ⇒ Object
47 48 49 50 51 52 |
# File 'lib/chef/formatters/error_descriptor.rb', line 47 def for_json() { 'title' => @title, 'sections' => @sections } end |
#section(heading, text) ⇒ Object
33 34 35 |
# File 'lib/chef/formatters/error_descriptor.rb', line 33 def section(heading, text) @sections << [heading, text] end |