Class: WavefrontDisplay::Write
- Defined in:
- lib/wavefront-cli/display/write.rb
Overview
Format human-readable output when writing points. In this context data is a Hash of the form { sent: 1, rejected: 0, unsent: 0 }
Direct Known Subclasses
Constant Summary
Constants included from WavefrontCli::Constants
WavefrontCli::Constants::ALL_PAGE_SIZE, WavefrontCli::Constants::DEFAULT_CONFIG, WavefrontCli::Constants::DEFAULT_OPTS, WavefrontCli::Constants::HUMAN_TIME_FORMAT, WavefrontCli::Constants::HUMAN_TIME_FORMAT_MS
Instance Attribute Summary collapse
-
#not_sent ⇒ Object
readonly
Returns the value of attribute not_sent.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#_prioritize_keys, #do_delete, #do_import, #do_list, #do_list_brief, #do_list_fields, #do_queries, #do_search, #do_search_brief, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #drop_fields, #filter_data, #filter_fields_as_arr, #friendly_name, #human_time, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #prioritize_keys, #priority_keys, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search, #time_formats
Constructor Details
This class inherits a constructor from WavefrontDisplay::Base
Instance Attribute Details
#not_sent ⇒ Object (readonly)
Returns the value of attribute not_sent.
9 10 11 |
# File 'lib/wavefront-cli/display/write.rb', line 9 def not_sent @not_sent end |
Instance Method Details
#do_file ⇒ Object
21 22 23 |
# File 'lib/wavefront-cli/display/write.rb', line 21 def do_file do_point end |
#do_point ⇒ Object
11 12 13 14 15 |
# File 'lib/wavefront-cli/display/write.rb', line 11 def do_point @not_sent = data['rejected'] + data['unsent'] report unless nothing_to_say? exit not_sent.zero? ? 0 : 1 end |
#nothing_to_say? ⇒ Boolean
17 18 19 |
# File 'lib/wavefront-cli/display/write.rb', line 17 def nothing_to_say? [:quiet] || not_sent.positive? end |
#report ⇒ Object
25 26 27 28 29 |
# File 'lib/wavefront-cli/display/write.rb', line 25 def report %w[sent rejected unsent].each do |k| puts format(' %12s %d', k.to_s, data[k]) end end |