Class: Chef::Formatters::Outputter
- Defined in:
- lib/chef/formatters/base.rb
Overview
Outputter
Handles basic printing tasks like colorizing. – TODO: Duplicates functionality from knife, upfactor.
Instance Attribute Summary collapse
-
#err ⇒ Object
readonly
Returns the value of attribute err.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
Instance Method Summary collapse
- #color(string, *colors) ⇒ Object (also: #print)
- #highline ⇒ Object
-
#initialize(out, err) ⇒ Outputter
constructor
A new instance of Outputter.
- #puts(string, *colors) ⇒ Object
Constructor Details
permalink #initialize(out, err) ⇒ Outputter
Returns a new instance of Outputter.
68 69 70 |
# File 'lib/chef/formatters/base.rb', line 68 def initialize(out, err) @out, @err = out, err end |
Instance Attribute Details
Instance Method Details
permalink #color(string, *colors) ⇒ Object Also known as: print
[View source]
79 80 81 82 83 84 85 |
# File 'lib/chef/formatters/base.rb', line 79 def color(string, *colors) if Chef::Config[:color] @out.print highline.color(string, *colors) else @out.print string end end |
permalink #highline ⇒ Object
[View source]
72 73 74 75 76 77 |
# File 'lib/chef/formatters/base.rb', line 72 def highline @highline ||= begin require 'highline' HighLine.new end end |
permalink #puts(string, *colors) ⇒ Object
[View source]
89 90 91 92 93 94 95 |
# File 'lib/chef/formatters/base.rb', line 89 def puts(string, *colors) if Chef::Config[:color] @out.puts highline.color(string, *colors) else @out.puts string end end |