midi-topaz 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/topaz/tempo.rb CHANGED
@@ -57,6 +57,11 @@ module Topaz
57
57
  def stop_when(&block)
58
58
  @source.action[:stop_when] = block
59
59
  end
60
+
61
+ # pass in a callback which will be fired on each tick
62
+ def on_tick(&block)
63
+ @source.action[:on_tick] = block
64
+ end
60
65
 
61
66
  # this will start the generator
62
67
  #
@@ -73,13 +78,14 @@ module Topaz
73
78
  def stop(options = {})
74
79
  @destinations.each { |dest| dest.on_stop }
75
80
  @source.stop(options)
81
+ @start_time = nil
76
82
  end
77
83
 
78
84
  # seconds since start was called
79
- def start_time
85
+ def time
80
86
  @start_time.nil? ? nil : (Time.now - @start_time).to_f
81
87
  end
82
- alias_method :time_since_start, :start_time
88
+ alias_method :time_since_start, :time
83
89
 
84
90
  private
85
91
 
data/lib/topaz.rb CHANGED
@@ -17,6 +17,6 @@ require 'topaz/tempo'
17
17
 
18
18
  module Topaz
19
19
 
20
- VERSION = "0.0.2"
20
+ VERSION = "0.0.3"
21
21
 
22
22
  end
@@ -17,5 +17,27 @@ class InternalTempoTest < Test::Unit::TestCase
17
17
 
18
18
  assert_equal(count_to, i)
19
19
  end
20
+
21
+ def test_change_on_click
22
+ i = 0
23
+ count_to = 5
24
+
25
+ tempo = Tempo.new(120) { i += 1 }
26
+ tempo.stop_when { i.eql?(count_to) }
27
+ tempo.start
28
+
29
+ assert_equal(count_to, i)
30
+
31
+ i = 0
32
+ count_to = 1000
33
+
34
+ tempo.on_tick { i += 100 }
35
+ tempo.stop_when { i.eql?(count_to) }
36
+ tempo.start
37
+
38
+ assert_equal(count_to, i)
39
+
40
+
41
+ end
20
42
 
21
43
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: midi-topaz
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ari Russo
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-28 00:00:00 -04:00
13
+ date: 2011-06-23 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency