Class: HammerCLI::Output::Adapter::Yaml

Inherits:
TreeStructure show all
Defined in:
lib/hammer_cli/output/adapter/yaml.rb

Instance Method Summary collapse

Methods inherited from TreeStructure

#features, #initialize, #prepare_collection, #prepare_message

Methods inherited from Abstract

#features, #initialize, #paginate_by_default?, #print_error, #tags

Constructor Details

This class inherits a constructor from HammerCLI::Output::Adapter::TreeStructure

Instance Method Details



9
10
11
12
13
14
15
# File 'lib/hammer_cli/output/adapter/yaml.rb', line 9

def print_collection(fields, collection, options = {})
  current_chunk = options[:current_chunk] || :single
  prepared = prepare_collection(fields, collection)
  result = YAML.dump(prepared)
  result = result[4..-1] unless %i[first single].include?(current_chunk)
  output_stream.puts result
end


17
18
19
20
# File 'lib/hammer_cli/output/adapter/yaml.rb', line 17

def print_message(msg, msg_params={})
  data = prepare_message(msg, msg_params)
  puts YAML.dump(data)
end


4
5
6
7
# File 'lib/hammer_cli/output/adapter/yaml.rb', line 4

def print_record(fields, record)
  result = prepare_collection(fields, [record].flatten(1))
  output_stream.puts YAML.dump(result.first)
end