Class: CommandExec::Formatter::JSON

Inherits:
Hash
  • Object
show all
Defined in:
lib/command_exec/formatter/json.rb

Overview

Style as json string

Instance Attribute Summary

Attributes inherited from Hash

#logger

Instance Method Summary collapse

Methods inherited from Hash

#initialize, #status

Methods included from CommandExec::FieldHelper

#end_time, #executable, #initialize, #log_file, #pid, #reason_for_failure, #return_code, #start_time, #stderr, #stdout

Constructor Details

This class inherits a constructor from CommandExec::Formatter::Hash

Instance Method Details

#output(*fields) ⇒ String

convert the prepared output to json

Parameters:

  • fields (Array, Symbol)

    the fields which should be outputted

Returns:

  • (String)

    the output formatted as json string



17
18
19
# File 'lib/command_exec/formatter/json.rb', line 17

def output(*fields)
  ::JSON.generate prepare_output(fields.flatten) 
end