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.
15 16 17 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 15 def initialize(entry) @entry = entry end |
Instance Attribute Details
#entry ⇒ Entry (readonly)
Returns The entry to format.
20 21 22 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 20 def entry @entry end |
Instance Method Details
#to_s ⇒ String
Format entry to a string to put on the output.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/benchmark/memory/job/io_output/entry_formatter.rb', line 25 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 |