Class: SensuGenerator::Trigger
- Inherits:
-
Object
- Object
- SensuGenerator::Trigger
- Defined in:
- lib/sensu_generator/trigger.rb
Instance Attribute Summary collapse
-
#last ⇒ Object
readonly
Returns the value of attribute last.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
Instance Method Summary collapse
- #clear ⇒ Object
- #difference_between_touches ⇒ Object
-
#initialize ⇒ Trigger
constructor
A new instance of Trigger.
- #last_touch_age ⇒ Object
- #logger ⇒ Object
- #modified_since_last_update? ⇒ Boolean
- #touch ⇒ Object
Constructor Details
#initialize ⇒ Trigger
Returns a new instance of Trigger.
5 6 7 8 9 |
# File 'lib/sensu_generator/trigger.rb', line 5 def initialize init_value = Time.now.to_f @previous = init_value @last = init_value end |
Instance Attribute Details
#last ⇒ Object (readonly)
Returns the value of attribute last.
3 4 5 |
# File 'lib/sensu_generator/trigger.rb', line 3 def last @last end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
3 4 5 |
# File 'lib/sensu_generator/trigger.rb', line 3 def previous @previous end |
Instance Method Details
#clear ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sensu_generator/trigger.rb', line 25 def clear logger.info "Clear trigger!" time = Time.now.to_f @previous = time @last = time end |
#difference_between_touches ⇒ Object
17 18 19 |
# File 'lib/sensu_generator/trigger.rb', line 17 def difference_between_touches @last - @previous end |
#last_touch_age ⇒ Object
21 22 23 |
# File 'lib/sensu_generator/trigger.rb', line 21 def last_touch_age Time.now.to_f - @last end |
#logger ⇒ Object
36 37 38 |
# File 'lib/sensu_generator/trigger.rb', line 36 def logger @logger ||= Application.logger end |
#modified_since_last_update? ⇒ Boolean
32 33 34 |
# File 'lib/sensu_generator/trigger.rb', line 32 def modified_since_last_update? @previous != @last end |
#touch ⇒ Object
11 12 13 14 15 |
# File 'lib/sensu_generator/trigger.rb', line 11 def touch logger.info "Touch trigger!" @previous = @last @last = Time.now.to_f end |