Class: ProcessHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/extensions/processmanager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, clazz) ⇒ ProcessHandler

Returns a new instance of ProcessHandler.



31
32
33
34
35
36
37
38
39
40
# File 'lib/sinatra/extensions/processmanager.rb', line 31

def initialize(id, name, clazz)
  @id = id
  @total = 0
  @performed = 0
  @log = []
  @error = ""
  @interrupted = false
  @name = name
  @clazz = clazz
end

Instance Attribute Details

#clazzObject (readonly)

Returns the value of attribute clazz.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def clazz
  @clazz
end

#errorObject (readonly)

Returns the value of attribute error.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def id
  @id
end

#interruptedObject (readonly)

Returns the value of attribute interrupted.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def interrupted
  @interrupted
end

#log(severity, message) ⇒ Object (readonly)

Returns the value of attribute log.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def log
  @log
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def name
  @name
end

#performedObject (readonly)

Returns the value of attribute performed.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def performed
  @performed
end

#totalObject

Returns the value of attribute total.



28
29
30
# File 'lib/sinatra/extensions/processmanager.rb', line 28

def total
  @total
end

Instance Method Details

#increaseObject



47
48
49
# File 'lib/sinatra/extensions/processmanager.rb', line 47

def increase
  @performed += 1
end

#interruptObject



55
56
57
# File 'lib/sinatra/extensions/processmanager.rb', line 55

def interrupt
  @interrupted = true
end

#interrupted?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/sinatra/extensions/processmanager.rb', line 59

def interrupted?
  @interrupted
end

#progressObject



42
43
44
45
# File 'lib/sinatra/extensions/processmanager.rb', line 42

def progress
  return 0 if @total == 0
  (@performed.to_f / @total.to_f)*100.0
end

#running?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/sinatra/extensions/processmanager.rb', line 63

def running?
  @total != @performed
end