Class: Igp::Base::Format
- Inherits:
-
Object
- Object
- Igp::Base::Format
- Defined in:
- lib/igp/base.rb
Overview
handle output formating tasks
Constant Summary collapse
- TIME_FORMAT =
'%Y-%m-%dT%H:%M:%S.%LZ'.freeze
Instance Method Summary collapse
-
#duration(duration) ⇒ Object
formats the duration for output.
-
#header(*args) ⇒ Object
prints the header structure to STDERR.
-
#log(*args) ⇒ Object
logs ping result to STDOUT
args
is an array of values to log.
Instance Method Details
#duration(duration) ⇒ Object
formats the duration for output. nil duration remains nil
76 77 78 |
# File 'lib/igp/base.rb', line 76 def duration(duration) format('%.6f', duration) if duration end |
#header(*args) ⇒ Object
prints the header structure to STDERR
64 65 66 |
# File 'lib/igp/base.rb', line 64 def header(*args) $stderr.puts(args.compact.join(' ')) end |
#log(*args) ⇒ Object
logs ping result to STDOUT args
is an array of values to log
70 71 72 73 |
# File 'lib/igp/base.rb', line 70 def log(*args) $stdout.puts(([Time.now.utc.strftime(TIME_FORMAT)] + args).join(',')) $stdout.flush end |