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

Class Method Details

.coerce_argument(arg) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/ruby-osc.rb', line 25

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:



33
34
35
# File 'lib/ruby-osc.rb', line 33

def self.decode str #:nodoc:
  str.match(/^#bundle/) ? Bundle.decode(str) : Message.decode(str)
end

.encoding_directive(obj) ⇒ Object

:nodoc:



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ruby-osc.rb', line 49

def self.encoding_directive obj #:nodoc:
  case obj
  when Float  then [obj, 'f', 'g']
  when Fixnum then [obj, 'i', 'N']
  when Blob   then [[obj.size, obj], 'b', "Na*x#{ padding_size obj.size + 4 }"]
  when String then [obj, 's', "Z*x#{ padding_size obj.size + 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



37
38
39
# File 'lib/ruby-osc.rb', line 37

def self.padding_size size
  (4 - (size) % 4) % 4 
end

.runObject



41
42
43
44
45
46
47
# File 'lib/ruby-osc.rb', line 41

def self.run
  EM.run do
    EM.error_handler { |e| puts e }
    EM.set_quantum 5 
    yield
  end
end