class Topaz::Clock::Event

Clock events

Attributes

clock[RW]

Public Class Methods

new() click to toggle source
# File lib/topaz/clock.rb, line 124
def initialize
  @start = []
  @stop = []
  @tick = []
end

Public Instance Methods

do_clock() click to toggle source

@return [Array]

# File lib/topaz/clock.rb, line 131
def do_clock
  !@clock.nil? && @clock.call
end
do_start() click to toggle source

@return [Array]

# File lib/topaz/clock.rb, line 147
def do_start
  @start.map(&:call)
end
do_stop() click to toggle source

@return [Array]

# File lib/topaz/clock.rb, line 163
def do_stop
  @stop.map(&:call)
end
do_tick() click to toggle source

@return [Array]

# File lib/topaz/clock.rb, line 179
def do_tick
  @tick.map(&:call)
end
start(&callback) click to toggle source

Pass in a callback that is called when start is called @param [Proc] callback @return [Array<Proc>]

# File lib/topaz/clock.rb, line 138
def start(&callback)
  if block_given?
    @start.clear
    @start << callback
  end
  @start
end
stop(&callback) click to toggle source

pass in a callback that is called when stop is called @param [Proc] callback @return [Array<Proc>]

# File lib/topaz/clock.rb, line 154
def stop(&callback)
  if block_given?
    @stop.clear
    @stop << callback
  end
  @stop
end
tick(&callback) click to toggle source

Pass in a callback which will be fired on each tick @param [Proc] callback @return [Array<Proc>]

# File lib/topaz/clock.rb, line 170
def tick(&callback)
  if block_given?
    @tick.clear
    @tick << callback
  end
  @tick
end