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

extract_nested_value format format_cookbook_list_for_display format_for_display format_list_for_display interchange? new parse_format_option summarize text_format

### Attributes

config | [R] |
ui | [R] |

### Public Class methods

new(ui, config)

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

extract_nested_value(data, nested_value_spec)
format(data)

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.

format_cookbook_list_for_display(item)
format_for_display(data)
format_list_for_display(list)
interchange?()

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.

parse_format_option()

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(data)

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

text_format(data)

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

[Validate]