Class: Dibber::ProcessLog

Inherits:
Object
  • Object
show all
Defined in:
lib/dibber/process_log.rb

Instance Method Summary collapse

Constructor Details

#initializeProcessLog

Returns a new instance of ProcessLog.



4
5
6
# File 'lib/dibber/process_log.rb', line 4

def initialize
  @log = {}
end

Instance Method Details

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/dibber/process_log.rb', line 32

def exists?(name)
  @log.keys.include?(name)
end

#finish(name) ⇒ Object



15
16
17
# File 'lib/dibber/process_log.rb', line 15

def finish(name)
  @log[name][:finish] = eval(@log[name][:command])
end

#rawObject



19
20
21
# File 'lib/dibber/process_log.rb', line 19

def raw
  @log
end

#reportObject



23
24
25
26
27
28
29
30
# File 'lib/dibber/process_log.rb', line 23

def report
  @report = []
  @log.each do |name, log|
    finish(name) unless @log[name][:finish]
    @report << "#{name.to_s.capitalize.gsub(/_/, ' ')} was #{log[:start]}, now #{log[:finish]}."
  end
  return @report
end

#start(name, command) ⇒ Object



8
9
10
11
12
13
# File 'lib/dibber/process_log.rb', line 8

def start(name, command)
  @log[name] = {
    :start => eval(command),
    :command => command
  }
end