Class: Salus::StdoutRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Salus::StdoutRenderer
- Defined in:
- lib/salus/renderer/stdout.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ StdoutRenderer
constructor
A new instance of StdoutRenderer.
- #render(data) ⇒ Object
Methods inherited from BaseRenderer
descendants, inherited, #iterate
Methods included from Logging
Constructor Details
#initialize(opts = {}) ⇒ StdoutRenderer
Returns a new instance of StdoutRenderer.
3 4 5 6 |
# File 'lib/salus/renderer/stdout.rb', line 3 def initialize(opts={}) super(opts) @precision = opts.fetch(:precision, 2) end |
Instance Method Details
#render(data) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/salus/renderer/stdout.rb', line 8 def render(data) iterate(data) do |name, metric| value = metric.value unless metric.is_a?(Salus::Text) value = "%.#{@precision}f" % value unless value.nil? end STDOUT.puts "[#{Time.at(metric.)}] #{name} - #{value}" unless metric..nil? end end |