Module: Decoder

Includes:
Constants, DecodingElementCheck
Included in:
RunLengthEncoding
Defined in:
lib/run_length_encoding/decoder.rb

Overview

Decode run-length encoded data.

Constant Summary

Constants included from Constants

Constants::CHUNK_KEY, Constants::COUNT_KEY

Instance Method Summary collapse

Instance Method Details

#decode(data) ⇒ Array

Pass data to the decoder.

Parameters:

  • data (Array<Hash{ Symbol => Object }>)

Returns:

  • (Array)

Raises:

  • (ArgumentError, TypeError)

    Raises if data isn’t an Array [TypeError] or an empty Array [ArgumentError].



23
24
25
26
27
28
29
# File 'lib/run_length_encoding/decoder.rb', line 23

def decode(data)
  ex_details = _check_dec_data(data)

  raise(ex_details[:ex_type], ex_details[:ex_msg]) if ex_details

  _decode(data)
end