Class: Autoperf::Display::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/autoperf/display/console.rb

Instance Method Summary collapse

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



28
29
30
# File 'lib/autoperf/display/console.rb', line 28

def print
  puts to_s
end

#tableObject



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_sObject



24
25
26
# File 'lib/autoperf/display/console.rb', line 24

def to_s
  @table.to_s
end