Class: Printer
- Inherits:
-
Object
- Object
- Printer
- Defined in:
- lib/busbar_cli/helpers/printer.rb
Class Method Summary collapse
- .print_reponse_for(response) ⇒ Object
- .print_resource(resource) ⇒ Object
- .print_result(result:, success_message:, failure_message:) ⇒ Object
Class Method Details
.print_reponse_for(response) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/busbar_cli/helpers/printer.rb', line 3 def print_reponse_for(response) if response.body.empty? puts "#{response.code} #{response.}" elsif response['Content-Type'].include?('application/json') puts JSON.pretty_generate(JSON.parse(response.body)) else puts response.body end end |
.print_resource(resource) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/busbar_cli/helpers/printer.rb', line 13 def print_resource(resource) if resource.nil? || !resource puts 'Resource not found' exit 0 end puts resource.as_text end |
.print_result(result:, success_message:, failure_message:) ⇒ Object
22 23 24 |
# File 'lib/busbar_cli/helpers/printer.rb', line 22 def print_result(result:, success_message:, failure_message:) puts result ? : end |