Class: Shattered::Timer::ContinuousTimedEvent

Inherits:
TimedEvent show all
Defined in:
lib/shattered_model/timed_event.rb

Instance Attribute Summary

Attributes inherited from TimedEvent

#time_remaining

Instance Method Summary collapse

Methods inherited from TimedEvent

#initialize, #stop, #stopped?

Constructor Details

This class inherits a constructor from Shattered::Timer::TimedEvent

Instance Method Details

#processed?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/shattered_model/timed_event.rb', line 114

def processed?
  false
end

#resetObject



110
111
112
113
# File 'lib/shattered_model/timed_event.rb', line 110

def reset
  @time_remaining += @initial_time
  @time_remaining = 0 if @time_remaining < 0
end

#update(time_elapsed) ⇒ Object



102
103
104
105
106
107
108
109
# File 'lib/shattered_model/timed_event.rb', line 102

def update(time_elapsed)
  return if stopped?
  @time_remaining -= time_elapsed
  if(time_up?)
    process_event
    reset
  end
end