Class: OSC::Message
- Extended by:
- Forwardable
- Defined in:
- lib/osc-ruby/message.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
include Enumerable.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
-
.new_with_time(address, time, tags = nil, *args) ⇒ Object
def_delegators(:@args, *de).
Instance Method Summary collapse
- #encode ⇒ Object
- #eql?(other) ⇒ Boolean
-
#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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/osc-ruby/message.rb', line 23 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
include Enumerable
6 7 8 |
# File 'lib/osc-ruby/message.rb', line 6 def address @address end |
#time ⇒ Object
Returns the value of attribute time.
7 8 9 |
# File 'lib/osc-ruby/message.rb', line 7 def time @time end |
Class Method Details
.new_with_time(address, time, tags = nil, *args) ⇒ Object
def_delegators(:@args, *de)
17 18 19 20 21 |
# File 'lib/osc-ruby/message.rb', line 17 def self.new_with_time( address, time, =nil, *args ) = new( address, , *args ) .time = time end |
Instance Method Details
#encode ⇒ Object
52 53 54 55 56 |
# File 'lib/osc-ruby/message.rb', line 52 def encode s = OSCString.new( @address ).encode s << OSCString.new( ',' + ).encode s << @args.collect{|x| x.encode}.join end |
#eql?(other) ⇒ Boolean
60 61 62 63 |
# File 'lib/osc-ruby/message.rb', line 60 def eql?( other ) @address == other.address && to_a == other.to_a end |
#tags ⇒ Object
50 |
# File 'lib/osc-ruby/message.rb', line 50 def () @args.collect{|x| x.tag}.join end |
#to_a ⇒ Object
58 |
# File 'lib/osc-ruby/message.rb', line 58 def to_a() @args.collect{|x| x.val} end |