Class: OSC::Message

Inherits:
Packet show all
Defined in:
lib/osc-ruby/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

decode

Constructor Details

#initialize(address, *args) ⇒ Message

Returns a new instance of Message.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/osc-ruby/message.rb', line 15

def initialize(address, *args)
  @address = address
  @args = []
  
  args.each_with_index do |arg, i|
    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

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/osc-ruby/message.rb', line 5

def address
  @address
end

#timeObject

Returns the value of attribute time.



6
7
8
# File 'lib/osc-ruby/message.rb', line 6

def time
  @time
end

Class Method Details

.new_with_time(address, time, tags = nil, *args) ⇒ Object



9
10
11
12
13
# File 'lib/osc-ruby/message.rb', line 9

def self.new_with_time( address, time, tags=nil, *args )
  message = new( address, tags, *args )
  message.time = time
  message
end

Instance Method Details

#encodeObject



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

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/osc-ruby/message.rb', line 40

def eql?( other )
  @address == other.address &&
  to_a == other.to_a
end

#tagsObject



30
# File 'lib/osc-ruby/message.rb', line 30

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

#to_aObject



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

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