Class OSC::Message
In: lib/osc.rb
Parent: Object

Methods

encode   new   to_s   to_yaml   types   typetag  

Included Modules

Enumerable

Attributes

address  [RW] 
args  [RW] 
source  [RW]  The source of this message, usually something like ["AF_INET", 50475, ‘localhost’,’127.0.0.1’]

Public Class methods

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.

[Source]

     # 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

Public Instance methods

Encode this message for transport

[Source]

     # File lib/osc.rb, line 137
137:     def encode
138:       Packet.encode(self)
139:     end

string representation. not the raw representation, for that use encode.

[Source]

     # File lib/osc.rb, line 142
142:     def to_s
143:       "#{address},#{types},#{args.collect{|a| a.to_s}.join(',')}"
144:     end

[Source]

     # File lib/osc.rb, line 145
145:     def to_yaml
146:       {'address'=>address, 'types'=>types, 'args'=>args}.to_yaml
147:     end

[Source]

     # File lib/osc.rb, line 131
131:     def types
132:       @args.collect {|a| Packet.tag a}.join
133:     end
typetag()

Alias for types

[Validate]