Class: QuickBase::EventNotifier::EventCheckPolicy
- Inherits:
-
Object
- Object
- QuickBase::EventNotifier::EventCheckPolicy
- Defined in:
- lib/QuickBaseEventNotifier.rb
Overview
Frequency and start/stop time of checking for TableEvent
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#nextCheckTime ⇒ Object
readonly
Returns the value of attribute nextCheckTime.
-
#numChecks ⇒ Object
readonly
Returns the value of attribute numChecks.
-
#numSuccessfulChecks ⇒ Object
readonly
Returns the value of attribute numSuccessfulChecks.
-
#starttime ⇒ Object
readonly
Returns the value of attribute starttime.
-
#stoptime ⇒ Object
readonly
Returns the value of attribute stoptime.
Instance Method Summary collapse
-
#initialize(interval = nil, starttime = nil, stoptime = nil, numChecks = -1,, numSuccessfulChecks = -1 )) ⇒ EventCheckPolicy
constructor
interval: minutes between checks starttime: start checking at this time stoptime: stop checking at this time numChecks: check this number of times then stop numSuccessfulChecks: stop checking after changes found this number of times.
- #setNextCheckTime(initializing = false, checkSucceeded = false) ⇒ Object
- #stopChecking? ⇒ Boolean
Constructor Details
#initialize(interval = nil, starttime = nil, stoptime = nil, numChecks = -1,, numSuccessfulChecks = -1 )) ⇒ EventCheckPolicy
interval: minutes between checks starttime: start checking at this time stoptime: stop checking at this time numChecks: check this number of times then stop numSuccessfulChecks: stop checking after changes found this number of times
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/QuickBaseEventNotifier.rb', line 275 def initialize(interval=nil,starttime=nil,stoptime=nil,numChecks=-1,numSuccessfulChecks=-1 ) if interval if interval.is_a?(Integer) and interval > 0 @interval = interval * 60 else raise "interval is not a positive number" end else @interval = 1 * 60 end if starttime if starttime.is_a?(Time) @starttime = starttime else raise "starttime must be a Time object" end else @starttime = Time.now end if stoptime and !stoptime.is_a?(Time) raise "stoptime must be a Time object" end @stoptime = stoptime if @starttime and @stoptime and @starttime > @stoptime raise "starttime must be before stoptime" end @numSuccessfulChecks = numSuccessfulChecks if @numSuccessfulChecks.nil? @numSuccessfulChecks = -1 elsif !@numSuccessfulChecks.is_a?(Integer) raise "numSuccessfulChecks must be a number" end if @numSuccessfulChecks > 0 @numChecks = -1 else @numChecks = numChecks if @numChecks.nil? @numChecks = -1 elsif !@numChecks.is_a?(Integer) raise "numChecks must be a number" end end setNextCheckTime(true) end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
268 269 270 |
# File 'lib/QuickBaseEventNotifier.rb', line 268 def interval @interval end |
#nextCheckTime ⇒ Object (readonly)
Returns the value of attribute nextCheckTime.
268 269 270 |
# File 'lib/QuickBaseEventNotifier.rb', line 268 def nextCheckTime @nextCheckTime end |
#numChecks ⇒ Object (readonly)
Returns the value of attribute numChecks.
268 269 270 |
# File 'lib/QuickBaseEventNotifier.rb', line 268 def numChecks @numChecks end |
#numSuccessfulChecks ⇒ Object (readonly)
Returns the value of attribute numSuccessfulChecks.
268 269 270 |
# File 'lib/QuickBaseEventNotifier.rb', line 268 def numSuccessfulChecks @numSuccessfulChecks end |
#starttime ⇒ Object (readonly)
Returns the value of attribute starttime.
268 269 270 |
# File 'lib/QuickBaseEventNotifier.rb', line 268 def starttime @starttime end |
#stoptime ⇒ Object (readonly)
Returns the value of attribute stoptime.
268 269 270 |
# File 'lib/QuickBaseEventNotifier.rb', line 268 def stoptime @stoptime end |
Instance Method Details
#setNextCheckTime(initializing = false, checkSucceeded = false) ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/QuickBaseEventNotifier.rb', line 320 def setNextCheckTime(initializing=false,checkSucceeded=false) if @nextCheckTime @nextCheckTime += @interval else @nextCheckTime = @starttime + @interval end if checkSucceeded and @numSuccessfulChecks > 0 @numSuccessfulChecks = @numSuccessfulChecks - 1 end @stopChecking = true if @numSuccessfulChecks == 0 if !initializing and @numChecks > 0 @numChecks = @numChecks - 1 @stopChecking = true if @numChecks == 0 end if !@stopChecking @stopChecking = (@stoptime and @nextCheckTime > @stoptime) end end |
#stopChecking? ⇒ Boolean
339 340 341 |
# File 'lib/QuickBaseEventNotifier.rb', line 339 def stopChecking? @stopChecking end |