Class: Groonga::QueryLog::Analyzer::Reporter

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/groonga/query-log/analyzer/reporter.rb

Direct Known Subclasses

ConsoleReporter, HTMLReporter, JSONReporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statistics) ⇒ Reporter

Returns a new instance of Reporter.



27
28
29
30
31
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 27

def initialize(statistics)
  @statistics = statistics
  @report_summary = true
  @output = $stdout
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



26
27
28
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 26

def output
  @output
end

Instance Method Details

#apply_options(options) ⇒ Object



33
34
35
36
37
38
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 33

def apply_options(options)
  self.output = options[:output] || @output
  unless options[:report_summary].nil?
    @report_summary = options[:report_summary]
  end
end

#eachObject



45
46
47
48
49
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 45

def each
  @statistics.each do |statistic|
    yield statistic
  end
end

#reportObject



51
52
53
54
55
56
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 51

def report
  setup do
    report_summary if @report_summary
    report_statistics
  end
end

#report_statisticsObject



58
59
60
61
62
# File 'lib/groonga/query-log/analyzer/reporter.rb', line 58

def report_statistics
  each do |statistic|
    report_statistic(statistic)
  end
end