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.
16 17 18 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 16 def initialize(entry) @entry = entry end |
Instance Attribute Details
#entry ⇒ Entry (readonly)
Returns The entry to format.
21 22 23 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 21 def entry @entry end |
Instance Method Details
#to_s ⇒ String
Format entry to a string to put on the output.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 26 def to_s output = StringIO.new output << rjust(entry.label) entry.measurement.each_with_index.map do |metric, index| output << " " * 20 unless index == 0 output << MetricFormatter.new(metric) output << "\n" end output.string end |