midi-eye 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 524bf91e8dbac58feee07b0f696a61ac76d7fb4b
4
- data.tar.gz: 7441878d91eedc9e9ebaa08a53667e4e58c9d8cf
3
+ metadata.gz: b47626fcd0bb5dcea8792ba0e9d78a40c432af06
4
+ data.tar.gz: 897075b6685648cbb7863e35d765f46d77400404
5
5
  SHA512:
6
- metadata.gz: 9ec47d24161b7c87e59f54bb0250a288e93cff135fcfc5e0dd958c21aacdd618b5f462be17c50835c51491053b2e9a2dedf6108b7c3c5f00c07d7e7e77c7e055
7
- data.tar.gz: e33ed2441cc4bebef9e79695345d313d222f8f152a8cad368654383c2e02f84d0c8334624d896308aea36b33d69718cbee8dbcc4db9c805a9aa930c8afa40aa9
6
+ metadata.gz: 1eae17bf98762357e26ca3bb855ded062cda3e4cd54e9f5a2431a2b9b4fc70b191f43128ebb1ed4f30a256aa00b58aab3bf9ac10731942eed63b10ee84425736
7
+ data.tar.gz: 3aa56326edc074401fffeaa1a881c7daa3bcc4d8cf7f6bfd873dfe79cc58b8e1d0b15b95692c08fd79c215876237d140f5757e2a879ec3fc6370738528fe3c12
data/lib/midi-eye.rb CHANGED
@@ -18,6 +18,6 @@ require "midi-eye/source"
18
18
 
19
19
  module MIDIEye
20
20
 
21
- VERSION = "0.3.3"
21
+ VERSION = "0.3.4"
22
22
 
23
23
  end
@@ -1,5 +1,6 @@
1
1
  module MIDIEye
2
2
 
3
+ # User defined callbacks for input events
3
4
  class Event
4
5
 
5
6
  def initialize
@@ -13,11 +14,18 @@ module MIDIEye
13
14
  @event.delete_if { |event| event[:listener_name].to_s == name.to_s }
14
15
  end
15
16
 
17
+ # Clear the collection of events
18
+ # @return [Boolean]
16
19
  def clear
17
20
  @event.clear
18
21
  @queue.clear
22
+ true
19
23
  end
20
24
 
25
+ # Add a user-defined input callback
26
+ # @param [Hash] options
27
+ # @param [Proc] callback
28
+ # @return [Hash]
21
29
  def add(options = {}, &callback)
22
30
  name = options[:listener_name]
23
31
  options.delete(:listener_name)
@@ -31,6 +39,7 @@ module MIDIEye
31
39
  end
32
40
 
33
41
  # Trigger all enqueued events
42
+ # @return [Fixnum] The number of triggered events
34
43
  def trigger_enqueued
35
44
  counter = 0
36
45
  while !@queue.empty? do
@@ -40,19 +49,25 @@ module MIDIEye
40
49
  counter
41
50
  end
42
51
 
52
+ # Enqueue all events with the given message
53
+ # @return [Array<Hash>]
43
54
  def enqueue_all(message)
44
- @event.each { |name| enqueue(name, message) }
55
+ @event.map { |action| enqueue(action, message) }
45
56
  end
46
57
 
47
- # Add an event to the trigger queue
58
+ # Add an event to the trigger queue
59
+ # @return [Hash]
48
60
  def enqueue(action, message)
49
61
  event = {
50
62
  :action => action,
51
63
  :message => message
52
64
  }
53
65
  @queue << event
66
+ event
54
67
  end
55
68
 
69
+ # The number of events
70
+ # @return [Fixnum]
56
71
  def count
57
72
  @event.count
58
73
  end
@@ -109,10 +109,8 @@ module MIDIEye
109
109
  objs.each do |batch|
110
110
  messages = [batch[:messages]].flatten.compact
111
111
  messages.each do |message|
112
- unless message.nil?
113
- data = { :message => message, :timestamp => batch[:timestamp] }
114
- @event.enqueue_all(data)
115
- end
112
+ data = { :message => message, :timestamp => batch[:timestamp] }
113
+ @event.enqueue_all(data)
116
114
  end
117
115
  end
118
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midi-eye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Russo