class WavefrontDisplay::Write

Format human-readable output when writing points. In this context data is a Hash of the form { sent: 1, rejected: 0, unsent: 0 }

Attributes

not_sent[R]

Public Instance Methods

do_file() click to toggle source
# File lib/wavefront-cli/display/write.rb, line 23
def do_file
  do_point
end
do_point() click to toggle source
# File lib/wavefront-cli/display/write.rb, line 13
def do_point
  @not_sent = data['rejected'] + data['unsent']
  report unless nothing_to_say?
  exit not_sent.zero? ? 0 : 1
end
nothing_to_say?() click to toggle source
# File lib/wavefront-cli/display/write.rb, line 19
def nothing_to_say?
  options[:quiet] || not_sent.positive?
end
report() click to toggle source
# File lib/wavefront-cli/display/write.rb, line 27
def report
  %w[sent rejected unsent].each do |status|
    puts format('  %12<status>s %<count>d',
                status: status,
                count: data[status])
  end
end