Class: Sequencer::EventTrigger

Inherits:
Object
  • Object
show all
Defined in:
lib/sequencer/event_trigger.rb

Overview

Callbacks that when evaluate to true, will trigger the corresponding sequencer event

Instance Method Summary collapse

Instance Method Details

#reset(&block) ⇒ Proc

Set the reset trigger. When true, the sequence will go back to step 0


9
10
11
# File 'lib/sequencer/event_trigger.rb', line 9

def reset(&block)
  @reset = block  
end

#reset?(pointer, data) ⇒ Boolean

Whether the reset event should fire


24
25
26
# File 'lib/sequencer/event_trigger.rb', line 24

def reset?(pointer, data)
  !@reset.nil? && @reset.call(pointer, data)
end

#reset_every(num) ⇒ Fixnum?

Shortcut to trigger a reset even on a given interval of ticks


66
67
68
69
70
71
72
73
# File 'lib/sequencer/event_trigger.rb', line 66

def reset_every(num)
  if num.nil?
    @reset = nil
  else
    reset { |pointer| pointer % num == 0 }
    num
  end
end

#rest(&block) ⇒ Proc

Set the rest trigger. When true, no messages will be outputted during that step


16
17
18
# File 'lib/sequencer/event_trigger.rb', line 16

def rest(&block)
  @rest = block
end

#rest?(pointer, data) ⇒ Boolean

Whether the rest event should fire


32
33
34
# File 'lib/sequencer/event_trigger.rb', line 32

def rest?(pointer, data)
  !@rest.nil? && @rest.call(pointer, data)
end

#rest_every(num) ⇒ Fixnum?

Shortcut to trigger a rest event on a given interval of ticks


54
55
56
57
58
59
60
61
# File 'lib/sequencer/event_trigger.rb', line 54

def rest_every(num)
  if num.nil?
    @rest = nil
  else
    rest { |pointer| pointer % num == 0 }
    num
  end
end

#stop(&block) ⇒ Proc

Set the stop trigger. When true, the sequencer will stop


39
40
41
# File 'lib/sequencer/event_trigger.rb', line 39

def stop(&block)
  @stop = block
end

#stop?(pointer, data) ⇒ Boolean

Whether to fire the stop event


47
48
49
# File 'lib/sequencer/event_trigger.rb', line 47

def stop?(pointer, data)
  !@stop.nil? && @stop.call(pointer, data)
end