Class: Repp::Ticker

Inherits:
Object
  • Object
show all
Defined in:
lib/repp/ticker.rb

Defined Under Namespace

Classes: Task

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Ticker

Returns a new instance of 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