Class: Vizcore::Sync::OscMessage::Parser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/sync/osc_message.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Parser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Parser.

Parameters:

  • data (String)


33
34
35
36
# File 'lib/vizcore/sync/osc_message.rb', line 33

def initialize(data)
  @data = data.to_s.b
  @offset = 0
end

Instance Method Details

#read_arguments(tags) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • tags (String, nil)

Returns:

  • (Array)


52
53
54
55
56
57
58
59
# File 'lib/vizcore/sync/osc_message.rb', line 52

def read_arguments(tags)
  return [] if tags.to_s.empty?
  return [] unless tags.start_with?(",")

  tags[1..].to_s.each_char.map do |tag|
    read_argument(tag)
  end
end

#read_stringString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String, nil)


39
40
41
42
43
44
45
46
47
48
# File 'lib/vizcore/sync/osc_message.rb', line 39

def read_string
  start = @offset
  @offset += 1 while @offset < @data.bytesize && @data.getbyte(@offset) != 0
  return nil if @offset >= @data.bytesize

  value = @data.byteslice(start...@offset).to_s.force_encoding(Encoding::UTF_8)
  @offset += 1
  align_offset
  value
end