Class: ProcessHandler
- Inherits:
-
Object
- Object
- ProcessHandler
- Defined in:
- lib/sinatra/extensions/processmanager.rb
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#interrupted ⇒ Object
readonly
Returns the value of attribute interrupted.
-
#log(severity, message) ⇒ Object
readonly
Returns the value of attribute log.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#performed ⇒ Object
readonly
Returns the value of attribute performed.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #increase ⇒ Object
-
#initialize(id, name, clazz) ⇒ ProcessHandler
constructor
A new instance of ProcessHandler.
- #interrupt ⇒ Object
- #interrupted? ⇒ Boolean
- #progress ⇒ Object
- #running? ⇒ Boolean
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
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
28 29 30 |
# File 'lib/sinatra/extensions/processmanager.rb', line 28 def clazz @clazz end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
28 29 30 |
# File 'lib/sinatra/extensions/processmanager.rb', line 28 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/sinatra/extensions/processmanager.rb', line 28 def id @id end |
#interrupted ⇒ Object (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 |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/sinatra/extensions/processmanager.rb', line 28 def name @name end |
#performed ⇒ Object (readonly)
Returns the value of attribute performed.
28 29 30 |
# File 'lib/sinatra/extensions/processmanager.rb', line 28 def performed @performed end |
#total ⇒ Object
Returns the value of attribute total.
28 29 30 |
# File 'lib/sinatra/extensions/processmanager.rb', line 28 def total @total end |
Instance Method Details
#increase ⇒ Object
47 48 49 |
# File 'lib/sinatra/extensions/processmanager.rb', line 47 def increase @performed += 1 end |
#interrupt ⇒ Object
55 56 57 |
# File 'lib/sinatra/extensions/processmanager.rb', line 55 def interrupt @interrupted = true end |
#interrupted? ⇒ Boolean
59 60 61 |
# File 'lib/sinatra/extensions/processmanager.rb', line 59 def interrupted? @interrupted end |
#progress ⇒ Object
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
63 64 65 |
# File 'lib/sinatra/extensions/processmanager.rb', line 63 def running? @total != @performed end |