Class: Repp::Ticker
- Inherits:
-
Object
- Object
- Repp::Ticker
- Defined in:
- lib/repp/ticker.rb
Defined Under Namespace
Classes: Task
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(&block) ⇒ Ticker
constructor
A new instance of Ticker.
- #run! ⇒ Object
Constructor Details
#initialize(&block) ⇒ Ticker
22 23 24 |
# File 'lib/repp/ticker.rb', line 22 def initialize(&block) @block = block end |
Class Method Details
.task(app, &block) ⇒ Object
4 5 6 7 |
# File 'lib/repp/ticker.rb', line 4 def self.task(app, &block) Task.app = app new(&block) end |
Instance Method Details
#run! ⇒ Object
26 27 28 29 30 31 |
# File 'lib/repp/ticker.rb', line 26 def run! @task = Concurrent::TimerTask.new(execution_interval: 1) do @block.call(Task.new.tick(Event::Ticker.new(body: Time.now))) end @task.execute end |