Class Chef::Knife::Core::GenericPresenter
In: lib/chef/knife/core/generic_presenter.rb
Parent: Object

Chef::Knife::Core::GenericPresenter

 The base presenter class for displaying structured data in knife commands.
 This is not an abstract base class, and it is suitable for displaying
 most kinds of objects that knife needs to display.

Methods

Attributes

config  [R] 
ui  [R] 

Public Class methods

Instaniates a new GenericPresenter. This is generally handled by the Chef::Knife::UI object, though you need to match the signature of this method if you intend to use your own presenter instead.

Public Instance methods

Returns a String representation of data that is suitable for output to a terminal or perhaps for data interchange with another program. The representation of the data depends on the value of the `config[:format]` setting.

Is the selected output format a data interchange format? Returns true if the selected output format is json or yaml, false otherwise. Knife search uses this to adjust its data output so as not to produce invalid JSON output.

Converts the user-supplied value of `config[:format]` to a Symbol representing the desired output format.

Returns

returns one of :summary, :text, :json, :yaml, or :pp

Raises

Raises an ArgumentError if the desired output format could not be determined from the value of `config[:format]`

Summarize the data. Defaults to text format output, which may not be very summary-like

Converts the data to a String in the text format. Uses Chef::Knife::Core::TextFormatter

[Validate]