| Class | OSC::Message |
| In: |
lib/osc.rb
|
| Parent: | Object |
| address | [RW] | |
| args | [RW] | |
| source | [RW] | The source of this message, usually something like ["AF_INET", 50475, ‘localhost’,’127.0.0.1’] |
| address: | The OSC address (a String) |
| types: | The OSC type tags string |
| args: | arguments. must match type tags in arity |
Example:
Message.new('/foo','ff', Math::PI, Math::E)
Arguments will be coerced as indicated by the type tags. If types is nil, type tags will be inferred from arguments.
# File lib/osc.rb, line 100
100: def initialize(address, types=nil, *args)
101: if types and types.size != args.size
102: raise ArgumentError, 'type/args arity mismatch'
103: end
104:
105: @address = address
106: @args = []
107:
108: if types
109: args.each_with_index do |arg, i|
110: case types[i]
111: when ?i; @args << arg.to_i
112: when ?f; @args << arg.to_f
113: when ?s; @args << arg.to_s
114: when ?b; @args << Blob.new(arg)
115: else
116: raise ArgumentError, "unknown type tag '#{@types[i].inspect}'"
117: end
118: end
119: else
120: args.each do |arg|
121: case arg
122: when Fixnum,Float,String,TimeTag,Blob
123: @args << arg
124: else
125: raise ArgumentError, "Object has unknown OSC type: '#{arg}'"
126: end
127: end
128: end
129: end
Encode this message for transport
# File lib/osc.rb, line 137
137: def encode
138: Packet.encode(self)
139: end
# File lib/osc.rb, line 145
145: def to_yaml
146: {'address'=>address, 'types'=>types, 'args'=>args}.to_yaml
147: end