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, user_id) ⇒ ProcessHandler

Returns a new instance of ProcessHandler.



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

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

Instance Attribute Details

#clazzObject (readonly)

Returns the value of attribute clazz.



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

def clazz
  @clazz
end

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#interruptedObject (readonly)

Returns the value of attribute interrupted.



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

def interrupted
  @interrupted
end

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

Returns the value of attribute log.



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

def log
  @log
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#performedObject (readonly)

Returns the value of attribute performed.



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

def performed
  @performed
end

#totalObject

Returns the value of attribute total.



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

def total
  @total
end

#user_idObject (readonly)

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Instance Method Details

#increaseObject



49
50
51
# File 'lib/sinatra/extensions/processmanager.rb', line 49

def increase
  @performed += 1
end

#interruptObject



57
58
59
# File 'lib/sinatra/extensions/processmanager.rb', line 57

def interrupt
  @interrupted = true
end

#interrupted?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/sinatra/extensions/processmanager.rb', line 61

def interrupted?
  @interrupted
end

#progressObject



44
45
46
47
# File 'lib/sinatra/extensions/processmanager.rb', line 44

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

#running?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/sinatra/extensions/processmanager.rb', line 65

def running?
  @total != @performed
end