Module: ID3Tag::IOUtil

Defined in:
lib/id3tag/io_util.rb

Class Method Summary collapse

Class Method Details

.read_until_terminator(io, group_size) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/id3tag/io_util.rb', line 4

def self.read_until_terminator(io, group_size)
  result = []
  bytes = io.each_byte
  current_group = bytes.take(group_size)
  while current_group.size == group_size do
    break if current_group.all? { |byte| byte == 0 }
    result += current_group
    current_group = bytes.take(group_size)
  end
  result.pack("C*")
end