Class: EventedBluepill::ProcessConditions::ProcessCondition
- Inherits:
-
Coolio::TimerWatcher
- Object
- Coolio::TimerWatcher
- EventedBluepill::ProcessConditions::ProcessCondition
- Defined in:
- lib/evented_bluepill/process_conditions/process_condition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#every ⇒ Object
readonly
Returns the value of attribute every.
-
#fires ⇒ Object
readonly
Returns the value of attribute fires.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
-
#process_condition ⇒ Object
readonly
Returns the value of attribute process_condition.
Instance Method Summary collapse
- #check(value) ⇒ Object
- #clear_history! ⇒ Object
- #format_value(value) ⇒ Object
-
#initialize(name, process, options = {}) ⇒ ProcessCondition
constructor
A new instance of ProcessCondition.
- #run ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, process, options = {}) ⇒ ProcessCondition
Returns a new instance of ProcessCondition.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 16 def initialize(name, process, = {}) @name = name @logger = .delete(:logger) @fires = .delete(:fires) || :restart @every = .delete(:every) @times = .delete(:times) || [1,1] @times = [@times, @times] unless @times.is_a?(Array) # handles :times => 5 @process = process self.clear_history! super(@every, true) end |
Instance Attribute Details
#every ⇒ Object (readonly)
Returns the value of attribute every.
14 15 16 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 14 def every @every end |
#fires ⇒ Object (readonly)
Returns the value of attribute fires.
14 15 16 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 14 def fires @fires end |
#logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 13 def logger @logger end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 14 def name @name end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
14 15 16 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 14 def process @process end |
#process_condition ⇒ Object (readonly)
Returns the value of attribute process_condition.
14 15 16 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 14 def process_condition @process_condition end |
Instance Method Details
#check(value) ⇒ Object
35 36 37 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 35 def check(value) raise "Implement in subclass!" end |
#clear_history! ⇒ Object
43 44 45 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 43 def clear_history! @history = EventedBluepill::Util::RotationalArray.new(@times.last) end |
#format_value(value) ⇒ Object
39 40 41 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 39 def format_value(value) value end |
#run ⇒ Object
31 32 33 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 31 def run raise "Implement in subclass!" end |
#to_s ⇒ Object
47 48 49 50 |
# File 'lib/evented_bluepill/process_conditions/process_condition.rb', line 47 def to_s data = @history.collect {|v| "#{v.value}#{'*' unless v.critical}"}.join(", ") "#{@name}: [#{data}]" end |