Class: Chrono::Trigger

Inherits:
Object
  • Object
show all
Defined in:
lib/chrono/trigger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, &block) ⇒ Trigger

Returns a new instance of Trigger.



5
6
7
8
# File 'lib/chrono/trigger.rb', line 5

def initialize(source, &block)
  @source = source
  @block = block || -> {}
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/chrono/trigger.rb', line 3

def block
  @block
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/chrono/trigger.rb', line 3

def source
  @source
end

Instance Method Details

#onceObject



10
11
12
13
# File 'lib/chrono/trigger.rb', line 10

def once
  wait
  call
end

#runObject



15
16
17
# File 'lib/chrono/trigger.rb', line 15

def run
  loop { once }
end