class OSC::Bundle

Attributes

timetag[RW]

Public Class Methods

new(timetag=nil, *args) click to toggle source
# File lib/osc.rb, line 245
def initialize(timetag=nil, *args)
  @timetag = timetag
  @args = args
end

Public Instance Methods

encode() click to toggle source
# File lib/osc.rb, line 252
def encode()
  s = OSCString.new('#bundle').encode
  s << encode_timetag(@timetag)
  s << @args.collect{|x|
    x2 = x.encode; [x2.size].pack('N') + x2}.join
end
to_a() click to toggle source
# File lib/osc.rb, line 262
def to_a() @args.collect{|x| x.to_a} end

Private Instance Methods

encode_timetag(t) click to toggle source
# File lib/osc.rb, line 226
def encode_timetag(t)
  case t
  when NIL # immediately
    t1 = 0
    t2 = 1
  when Numeric
    t1, fr = t.divmod(1)
    t2 = (fr * (2**32)).to_i
  when Time
    t1, fr = (t.to_f + 2208988800).divmod(1)
    t2 = (fr * (2**32)).to_i
  else
    raise ArgumentError, 'invalid time'
  end
  [t1, t2].pack('N2')
end