Module: OSC
- Defined in:
- lib/ruby-osc/client.rb,
lib/ruby-osc.rb,
lib/ruby-osc/bundle.rb,
lib/ruby-osc/server.rb,
lib/ruby-osc/message.rb
Overview
From the Funaba osc gem:
Defined Under Namespace
Modules: OSCArgument Classes: Blob, Bundle, Client, DecodeError, Message, Server
Class Method Summary collapse
- .coerce_argument(arg) ⇒ Object
-
.decode(str) ⇒ Object
:nodoc:.
-
.encoding_directive(obj) ⇒ Object
:nodoc:.
- .padding_size(size) ⇒ Object
- .run ⇒ Object
Class Method Details
.coerce_argument(arg) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ruby-osc.rb', line 27 def self.coerce_argument arg case arg when OSCArgument then arg.to_osc_type when Symbol then arg.to_s when String, Float, Fixnum, Blob, String then arg # Pure osc 1.0 specification else raise(TypeError, "#{ arg.inspect } is not a valid Message argument") end end |
.decode(str) ⇒ Object
:nodoc:
35 36 37 |
# File 'lib/ruby-osc.rb', line 35 def self.decode str #:nodoc: str.match(/^#bundle/) ? Bundle.decode(str) : Message.decode(str) end |
.encoding_directive(obj) ⇒ Object
:nodoc:
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ruby-osc.rb', line 51 def self.encoding_directive obj #:nodoc: case obj when Float then [obj, 'f', 'g'] when Fixnum then [obj, 'i', 'N'] when Blob then [[obj.bytesize, obj], 'b', "Na*x#{ padding_size obj.bytesize + 4 }"] when String then [obj, 's', "Z*x#{ padding_size obj.bytesize + 1 }"] when Time t1, fr = (obj.to_f + 2208988800).divmod(1) t2 = (fr * (2**32)).to_i [[t1, t2], 't', 'N2'] end end |
.padding_size(size) ⇒ Object
39 40 41 |
# File 'lib/ruby-osc.rb', line 39 def self.padding_size size (4 - (size) % 4) % 4 end |
.run ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ruby-osc.rb', line 43 def self.run EM.run do EM.error_handler { |e| puts e } EM.set_quantum 5 yield end end |