Class: Benchmark::Memory::Job::IOOutput::EntryFormatter
- Inherits:
-
Object
- Object
- Benchmark::Memory::Job::IOOutput::EntryFormatter
- Includes:
- Helpers
- Defined in:
- lib/benchmark/memory/job/io_output/entry_formatter.rb
Overview
Format entries for use with the IOOutput.
Instance Attribute Summary collapse
-
#entry ⇒ Entry
readonly
The entry to format.
Instance Method Summary collapse
-
#initialize(entry) ⇒ EntryFormatter
constructor
Instantiate a formatter to output an entry into an IO.
-
#to_s ⇒ String
Format entry to a string to put on the output.
Methods included from Helpers
Constructor Details
#initialize(entry) ⇒ EntryFormatter
Instantiate a formatter to output an entry into an IO.
18 19 20 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 18 def initialize(entry) @entry = entry end |
Instance Attribute Details
#entry ⇒ Entry (readonly)
Returns The entry to format.
23 24 25 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 23 def entry @entry end |
Instance Method Details
#to_s ⇒ String
Format entry to a string to put on the output.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 28 def to_s output = StringIO.new output << rjust(entry.label) first, *rest = *entry.measurement output << "#{MetricFormatter.new(first)}\n" rest.each do |metric| output << "#{' ' * 20}#{MetricFormatter.new(metric)}\n" end output.string end |