Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added console and builder for message using tests
- Loading branch information
Showing
5 changed files
with
115 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
#!/bin/bash | |||
irb -r lib/osc-ruby.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
class MessageBuilder | |||
|
|||
def initialize | |||
@address = "" | |||
@tags = [] | |||
@values = [] | |||
end | |||
|
|||
def with_address( addr ) | |||
@address = addr | |||
self | |||
end | |||
|
|||
def with_float( float ) | |||
with_arg( "f", float ) | |||
self | |||
end | |||
|
|||
def with_int( int ) | |||
with_arg( "i", int ) | |||
self | |||
end | |||
|
|||
def with_string( string ) | |||
with_arg( "s", string ) | |||
self | |||
end | |||
|
|||
|
|||
def build | |||
OSC::Message.new( @address , @tags.join, *@values) | |||
end | |||
|
|||
private | |||
|
|||
def with_arg( tag, value ) | |||
@tags << tag | |||
@values << value | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
# some test data for when i unit test this | |||
# @simple_packet = "/hi\000,\000\000\000" | |||
# @simple_with_integer_arg = "/hi\000,i\000\000\000\000\000*" | |||
# @simple_with_two_integer_args = "/hi\000,ii\000\000\000\000*\000\000\000!" | |||
# @simple_with_float_arg = "/hi\000,f\000\000B(\n=" | |||
# @simple_with_two_float_args = "/hi\000,ff\000B(\n=B\004\n=" | |||
# @simple_with_string_arg = "/hi\000,s\000\000greetings\000\000\000" | |||
# @simple_with_two_string_args = "/hi\000,ss\000greetings\000\000\000how are you?\000\000\000\000" | |||
# @simple_with_int_float_string = "/hi\000,ifs\000\000\000\000\000\000\000*B\004\n=greetings\000\000\000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters