Class: OSC::Message
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/osc.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(address, tags = nil, *args) ⇒ Message
constructor
A new instance of Message.
- #tags ⇒ Object
- #to_a ⇒ Object
Methods inherited from Packet
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, =nil, *args) @address = address @args = [] args.each_with_index do |arg, i| if && [i] case [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
#address ⇒ Object
Returns the value of attribute address.
199 200 201 |
# File 'lib/osc.rb', line 199 def address @address end |
Instance Method Details
#encode ⇒ Object
203 204 205 206 207 |
# File 'lib/osc.rb', line 203 def encode s = OSCString.new(@address).encode s << OSCString.new().encode s << @args.collect{|x| x.encode}.join end |
#tags ⇒ Object
201 |
# File 'lib/osc.rb', line 201 def () ',' + @args.collect{|x| x.tag}.join end |
#to_a ⇒ Object
209 |
# File 'lib/osc.rb', line 209 def to_a() @args.collect{|x| x.val} end |