Class: Autoperf::Display::Console
- Inherits:
-
Object
- Object
- Autoperf::Display::Console
- Defined in:
- lib/autoperf/display/console.rb
Instance Method Summary collapse
-
#initialize(results, report = nil) ⇒ Console
constructor
A new instance of Console.
- #print ⇒ Object
- #table ⇒ Object
- #table_from_array(report) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(results, report = nil) ⇒ Console
Returns a new instance of Console.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/autoperf/display/console.rb', line 4 def initialize results, report=nil @table = if report.kind_of?(Array) table_from_array(report) elsif report.kind_of?(Ruport::Data::Table) report else # ignore input and use defaults table_from_array(::Autoperf::Display::DEFAULT_FIELDS) end results.each do |rate, result| result.merge!(:rate => rate) if @table.column_names.include?(:rate) @table << result end @table end |
Instance Method Details
#print ⇒ Object
28 29 30 |
# File 'lib/autoperf/display/console.rb', line 28 def print puts to_s end |
#table ⇒ Object
20 21 22 |
# File 'lib/autoperf/display/console.rb', line 20 def table @table end |
#table_from_array(report) ⇒ Object
32 33 34 |
# File 'lib/autoperf/display/console.rb', line 32 def table_from_array report Table(:column_names => report) end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/autoperf/display/console.rb', line 24 def to_s @table.to_s end |