Class: AudioTag::ID3::Synchsafe

Inherits:
Object
  • Object
show all
Defined in:
lib/audio_tag/id3/synchsafe.rb

Defined Under Namespace

Classes: InvalidBytesError

Constant Summary collapse

MAX_BYTE =
128

Class Method Summary collapse

Class Method Details

.parse(*bytes) ⇒ Object

Raises:



10
11
12
13
14
15
16
# File 'lib/audio_tag/id3/synchsafe.rb', line 10

def self.parse(*bytes)
  raise InvalidBytesError if bytes.any? { |byte| byte >= MAX_BYTE }

  bytes.reverse_each.with_index.map do |byte, index|
    byte << (7 * index)
  end.reduce(:|)
end