Class: HammerCLI::Output::Adapter::Yaml
- Inherits:
-
TreeStructure
- Object
- Abstract
- TreeStructure
- HammerCLI::Output::Adapter::Yaml
- Defined in:
- lib/hammer_cli/output/adapter/yaml.rb
Instance Method Summary collapse
- #print_collection(fields, collection, options = {}) ⇒ Object
- #print_message(msg, msg_params = {}) ⇒ Object
- #print_record(fields, record) ⇒ Object
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
#print_collection(fields, collection, options = {}) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/hammer_cli/output/adapter/yaml.rb', line 9 def print_collection(fields, collection, = {}) current_chunk = [: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 |
#print_message(msg, msg_params = {}) ⇒ Object
17 18 19 20 |
# File 'lib/hammer_cli/output/adapter/yaml.rb', line 17 def (msg, msg_params={}) data = (msg, msg_params) puts YAML.dump(data) end |
#print_record(fields, record) ⇒ Object
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 |