Class: NexposeTicketing::TicketMetrics

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose_ticketing/ticket_metrics.rb

Constant Summary collapse

@@ticket_counts =

Create the specific metric collecting methods

{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTicketMetrics

Returns a new instance of TicketMetrics.



18
19
20
21
# File 'lib/nexpose_ticketing/ticket_metrics.rb', line 18

def initialize
  @start_time = nil
  @log = NexposeTicketing::NxLogger.instance
end

Instance Attribute Details

#ticket_countsObject

Returns the value of attribute ticket_counts.



3
4
5
# File 'lib/nexpose_ticketing/ticket_metrics.rb', line 3

def ticket_counts
  @ticket_counts
end

Instance Method Details

#finishObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/nexpose_ticketing/ticket_metrics.rb', line 28

def finish
  return if @start_time == nil  
  @time_taken = Time.at(Time.now - @start_time).utc.strftime('%H:%M:%S')
  @start_time = nil

  @log.log_message("Ticket processing took #{@time_taken} to complete.")
  @@ticket_counts.keys.each do |action|
    @log.log_message("Metrics: #{@@ticket_counts[action]} tickets were #{action}.")
  end
end

#startObject



23
24
25
26
# File 'lib/nexpose_ticketing/ticket_metrics.rb', line 23

def start
  return if @start_time != nil
  @start_time = Time.now
end