Class: Benchmark::Memory::Job::IOOutput::ComparisonFormatter
- Inherits:
-
Object
- Object
- Benchmark::Memory::Job::IOOutput::ComparisonFormatter
- Includes:
- Helpers
- Defined in:
- lib/benchmark/memory/job/io_output/comparison_formatter.rb
Overview
Format a comparison for use with the IOOutput.
Instance Attribute Summary collapse
-
#comparison ⇒ Report::Comparison
readonly
The comparison to format.
Instance Method Summary collapse
-
#initialize(comparison) ⇒ ComparisonFormatter
constructor
Instantiate a formatter to output an comparison into an IO.
-
#to_s ⇒ String
Format comparison to a string to put on the output.
Methods included from Helpers
Constructor Details
#initialize(comparison) ⇒ ComparisonFormatter
Instantiate a formatter to output an comparison into an IO.
15 16 17 |
# File 'lib/benchmark/memory/job/io_output/comparison_formatter.rb', line 15 def initialize(comparison) @comparison = comparison end |
Instance Attribute Details
#comparison ⇒ Report::Comparison (readonly)
Returns The comparison to format.
20 21 22 |
# File 'lib/benchmark/memory/job/io_output/comparison_formatter.rb', line 20 def comparison @comparison end |
Instance Method Details
#to_s ⇒ String
Format comparison to a string to put on the output.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/benchmark/memory/job/io_output/comparison_formatter.rb', line 25 def to_s return "" unless comparison.possible? output = StringIO.new best, *rest = comparison.entries rest = Array(rest) add_best_summary(best, output) rest.each do |entry| add_comparison(entry, best, output) end output.string end |