Class: RubyScriptExporter::Formatter
- Inherits:
-
Object
- Object
- RubyScriptExporter::Formatter
- Defined in:
- lib/ruby_script_exporter/formatter.rb
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(measurements) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(measurements) ⇒ Formatter
Returns a new instance of Formatter.
4 5 6 |
# File 'lib/ruby_script_exporter/formatter.rb', line 4 def initialize(measurements) @measurements = measurements end |
Instance Method Details
#format ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby_script_exporter/formatter.rb', line 8 def format output = [] @measurements .group_by(&:measurement) .sort_by { |key, _| key } .map do |type, measurements| type = Type.from_name(type) output << type.format_for_open_metrics measurements.each do |measurement| output << measurement.format_as_open_metric end end output.join("\n") end |