Class: OSC::Message

Inherits:
Packet show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/osc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

decode

Constructor Details

#initialize(address, tags = nil, *args) ⇒ Message

Returns a new instance of Message.



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/osc.rb', line 175

def initialize(address, tags=nil, *args)
  @address = address
  @args = []
  args.each_with_index do |arg, i|
  if tags && tags[i]
    case tags[i]
    when ?i; @args << OSCInt32.new(arg)
    when ?f; @args << OSCFloat32.new(arg)
    when ?s; @args << OSCString.new(arg)
    when ?b; @args << OSCBlob.new(arg)
    when ?*; @args << arg
    else; raise ArgumentError, 'unknown type'
    end
  else
    case arg
    when Integer;     @args << OSCInt32.new(arg)
    when Float;       @args << OSCFloat32.new(arg)
    when String;      @args << OSCString.new(arg)
    when OSCArgument; @args << arg
    end
  end
  end
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



199
200
201
# File 'lib/osc.rb', line 199

def address
  @address
end

Instance Method Details

#encodeObject



203
204
205
206
207
# File 'lib/osc.rb', line 203

def encode
  s = OSCString.new(@address).encode
  s << OSCString.new(tags).encode
  s << @args.collect{|x| x.encode}.join
end

#tagsObject



201
# File 'lib/osc.rb', line 201

def tags() ',' + @args.collect{|x| x.tag}.join end

#to_aObject



209
# File 'lib/osc.rb', line 209

def to_a() @args.collect{|x| x.val} end