Skip to content

Commit

Permalink
osc_receive :accessor option
Browse files Browse the repository at this point in the history
  • Loading branch information
arirusso committed Oct 28, 2011
1 parent f6bd9d4 commit c10f6c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/osc-access/accessible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def osc_on_receive(msg, options = {}, &block)
val = osc_process_arg_option(msg, options)
val = osc_translate(val, options[:translate]) unless options[:translate].nil?
osc_send(msg) if options[:thru]
accessor = options[:accessor]
self.send("#{accessor.to_s}=", val) unless accessor.nil?
yield(self, val, msg) unless block.nil?

end

private
Expand Down
11 changes: 11 additions & 0 deletions test/test_accessible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ def test_osc_receive_arg
assert_equal(4, received)
end

def test_osc_receive_accessor
sleep(0.5)
obj = StubObject.new
obj.osc_start(:input_port => 8084)
obj.osc_receive("/test_osc_receive_accessor", :accessor => :data)
client = OSC::Client.new("localhost", 8084)
client.send( OSC::Message.new( "/test_osc_receive_accessor", "hi from test_osc_receive_accessor"))
sleep(0.5)
assert_equal("hi from test_osc_receive_accessor", obj.data)
end

def test_load_map_inline_proc
received = nil
map = {
Expand Down

0 comments on commit c10f6c1

Please sign in to comment.